[LRUG] Rails: Loading A Plugin On Each Request

Andrew Stewart boss at airbladesoftware.com
Mon Jan 7 01:23:24 PST 2008


Hi Everyone,

Rails changeset 8116 ensures that plugins are only loaded once:

http://dev.rubyonrails.org/changeset/8116

When developing plugins it's useful to have them reloaded on each  
request, like normal application code.  This used to work but doesn't  
any more:

vendor/plugins/some_plugin/init.rb:

   lib = File.expand_path(File.join(__FILE__, '..', 'lib'))
   Dependencies.load_once_paths.delete(lib)

I also tried this at the top of config/environment.rb, just before  
the rails initializer block, but it didn't work either:

   module Rails
     class Plugin
       def load(initializer)
         # return if loaded?   <- we don't want to execute this
         report_nonexistant_or_empty_plugin! unless valid?
         evaluate_init_rb(initializer)
         @loaded = true
       end
     end
   end

Does anybody know how I can get a plugin to reload in development?

Thanks and regards,
Andy Stewart

-------
http://airbladesoftware.com






More information about the Chat mailing list