I ran into this problem too when I ripped all the code from my generic application into an engine and found the methods I had in application.rb were missing.
The explanations in this thread make sense. The question I have is what the best practice is for enginizing an application.rb? When I ran generate engine, I found that a module was created in lib with my engine's name and that a subdirectory was made in lib with the name as well. The module has a commented out line for including files from that subdirectory. The documentation for using an engine says to add an include line in your application controller referencing this module, but it seems like this module is for more universal things than just mixins for ApplicationController, so I was thinking maybe I should create a new module named something like: module EngineApplicationControllerMixins def mymethod end end and include that module in my host application's application.rb controller. If I did that, I wouldn't need to include the main module in ApplicationController unless at some point I added code to it. Before I go this route, I just wanted to post this message and see if I was missing anything that would cause me trouble down the road. Thanks, Daniel "James Adam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 3/22/06, Lance Ditkins <[EMAIL PROTECTED]> wrote: >> After some more digging around, I realized that the include line that >> engines require in the application.rb and application_helper.rb load the >> default module in the engines' /lib directory. So I'll just stick the >> methods in there. (Right?) > > That'd be a sensible place, yeah. Just put those methods into a module > and either include it manually in your application, or send > ApplicationController (or ActionController::Base, probably) an > :include message from your init[_engine].rb to have it work > automagically. > >> P.S. Engines have been a lifesaver for me so far. Thanks to the >> developers for all of the hard work. > > Glad you're finding them useful :) > > -- > * J * > ~ _______________________________________________ engine-developers mailing list [email protected] http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org
