I would almost certainly recommend against your approach :S By placing
application.rb within your engine, you are locking it away from the
user, and therefore preventing them from adding any of their own logic
to the ApplicationController class. If the user tries to create their
own ‘application.rb’ file in /app/controllers, your engine file will
no longer be loaded.
Current ‘best practice’ would be to wrap your methods in a module and
either have the user include this module in their
ApplicationController class, or automatically include it in
ActionController::Base by sending an :include message in your
init_engine.rb (you can’t reliably send the include to
ApplicationController because this class gets reloaded in development
mode, whilst init_engine.rb files are only evaluated at startup).
For your particular engine, you could replace your application.rb with
$cache ||= SimpleCache.new 1.hour
… and then have the user include that in their own
ApplicationController (bear in mind that is untested code, I’m just
writing it from memory of how these things should work).
On 3/23/06, Seth firstname.lastname@example.org wrote:
Posted via http://www.ruby-forum.com/.
engine-developers mailing list