-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there anyway to extend the Team model to add my own attributes? #153
Comments
I monkey patch these in my projects.
There should be a cleaner way. |
I attempted to do that but couldn't get it to work. Not sure what I did incorrectly, is there a special way I need to tell rails to load the new class other than placing it the models directory of Rails? |
I don't think so. Example: https://github.com/dblock/slack-sup/blob/master/slack-sup/models/team.rb Put up a small app and show how it's not working? |
I'll try and put something together to demonstrate. (Leaving some notes here to help me in a bit.) Rails Version: 7.0.4 Gist: https://gist.github.com/Altonymous/96fb6c07294b86de0ea343ce007a4dbe |
Here's an example I put together, hopefully this is what helps. https://github.com/Altonymous/example_app/blob/main/README.md |
Found this StackOverflow, finally. (Google-fu Skill: +1) https://stackoverflow.com/a/48665268 The "answer" doesn't do it, but the one made by "Carles Jove i Buxeda" seems to work for the example_app I posted. (I haven't updated it yet, in case this isn't a good way to handle it.) Going to see how it works in my actual application now. |
@Altonymous Thanks. I'd like this to be documented, but even more I'd like https://github.com/slack-ruby/slack-bot-on-rails to be updated to the latest version of slack-ruby-bot-server and its libraries. Maybe you can help? |
Hi all, is there a way to extend the Team model? I'm using Rails 6 btw. I've tried: # lib/extensions/slack_ruby_bot_server/team.rb
module Extensions
module SlackRubyBotServer
module Team
extend ActiveSupport::Concern
included do
def self.color
'blue'
end
end
end
end
end # config/initializers/slack_ruby_bot_server.rb
require 'extensions/slack_ruby_bot_server/team'
SlackRubyBotServer.configure do |config|
config.oauth_version = :v2
config.oauth_scope = ENV.fetch('SLACK_OAUTH_SCOPE').split(/\s*,\s*/)
end
Rails.application.config.to_prepare do
begin
if ActiveRecord::Base.connection.table_exists?(:teams)
SlackRubyBotServer::Models::Team.include(Extensions::SlackRubyBotServer::Team)
end
rescue ActiveRecord::NoDatabaseError
end
end But couldn't find how slack ruby bot server exposes the model's directory. It says: Could you help me? |
I still just monkey-patch the |
Where to put this new team model? I did put it on |
If you want to upgrade https://github.com/slack-ruby/slack-bot-on-rails and try adding it to that I can take a look. |
Referencing this model:
The text was updated successfully, but these errors were encountered: