Skip to content

Instantly share code, notes, and snippets.

@kamal
Forked from stympy/subscription_plan.rb
Created April 29, 2011 14:02
Show Gist options
  • Save kamal/948343 to your computer and use it in GitHub Desktop.
Save kamal/948343 to your computer and use it in GitHub Desktop.
Extending a model in a Rails 3 (pre-3.1) engine
module BabyTalk
class Engine < Rails::Engine
config.to_prepare do
User.class_eval do
has_many :participations, :foreign_key => "participant_id"
has_many :rooms, :through => :participations
end
end
end
end
@fadhlirahim
Copy link

Thanks for this Kamal. Very uncanny ~ i was thinking about doing the same thing

@julesce
Copy link

julesce commented Mar 19, 2012

I see that you mention that this is for pre-3.1... how would this code change in rails 3.2.2 for example?

@kamal
Copy link
Author

kamal commented Mar 26, 2012 via email

@julesce
Copy link

julesce commented Mar 26, 2012

Ah don't worry, I figured out that the issue I had was unrelated to this. Thanks though :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment