Created
July 12, 2012 02:43
-
-
Save johnmcaliley/3095339 to your computer and use it in GitHub Desktop.
Reopen rails engine model in app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails 3.2.6 | |
# my_engine/app/models/user.rb | |
# Define class in engine | |
class User < ActiveRecord::Base | |
#methods here | |
end | |
# my_rails_app/app/models/user.rb | |
# Require the engine model first and then reopen it to add new methods, associations, etc | |
require MyEngine::Engine.root.join('app', 'models', 'user') | |
class User | |
#new methods here | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rather than reopen the classes, I think I am going to implore this strategy.
https://gist.github.com/3132025
From your time with Rails Engines, will this cause problems in the long run?
The advice I have gotten so far says no.
https://groups.google.com/forum/?fromgroups#!topic/rubyonrails-core/jy2dQ0BQhnM