Hi! This is an advanced question related to Rails engines and classes loading
in development mode in Rails 3.1
Lets say there is a gem-rails-engine "foo" that provides Bar model, and I
would like to develop "foo-zoo" gem that adds module Zoo to Bar. So the
"include Zoo" code should be evaluated in the context of Bar class when the
last is loaded.
One way to achieve this is using "to_prepare" method in "foo-zoo" Engine. In
production mode, the class should be loaded once. The problem comes in
development mode. This loading slows the asset pipeline, because Bar is
reloaded every time an asset is served (though it is not needed).
Another option is maybe using the "on_load" hook, but I think it does not work
for every class.
Does anybody know a better way to do this?