[LRUG] Rails: Loading A Plugin On Each Request
James Adam
james.adam at gmail.com
Mon Jan 7 02:37:07 PST 2008
Everyone seems to be asking this question recently. There are a few
approaches - here's some background:
http://dev.rubyonrails.org/ticket/10488
http://lists.rails-engines.org/pipermail/engine-users-rails-engines.org/2008-January/000629.html
The email to the engines list seems to imply that deleting the lib
path from load_once_paths does work - I don't think that having the
engines plugin in an application would make this work when otherwise
it wouldn't.
Another approach is to simply empty load_once_paths in development;
see the Rails ticket for more about that.
A third approach is to ensure that all of your classes are explicitly
loaded using require_dependency, although this might be less
practical.
HTH
James
On 1/7/08, Andrew Stewart <boss at airbladesoftware.com> wrote:
> 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
>
>
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
--
* J *
~
More information about the Chat
mailing list