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?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to