Hi list.
I know that it is currently hard to override anything in the model
classes of an Engine. What about the following:
Engines includes the file RAILS_ROOT/app/components/engine_models.rb
after the last model require. In this file, you can have code like:
class MyModel
has_many :foo
end
So you can mix in code there.
Would this work, James?
Regards,
Manuel
on 2006-03-04 12:18
on 2006-03-06 17:05
I'm not very keen on putting models in files other than <model_name>.rb, since this fits best with Rails' own scheme and will work with the auto-dependency loading too. The 'best practice' at the moment is to only provide stub models in your engine, and use meta programming along with modules to include functionality. Take a look at the login/user engines' User model classes for an example of this. The advantage of doing it this way is that an end-user-developer can override methods by creating their own model class, adding the 'include' lines and then redefining any methods that they want. It's not perfect, but it's literally only a couple of lines more than the controlller/helper mixing. - james On 3/4/06, Manuel Holtgrewe <purestorm@ggnore.net> wrote: > end > engine-developers mailing list > engine-developers@lists.rails-engines.org > http://lists.rails-engines.org/listinfo.cgi/engine... > -- * J * ~
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.