threadsafe! & engines

320 views
Skip to first unread message

Tyler Jennings

unread,
Jul 30, 2009, 12:35:35 PM7/30/09
to rubyonra...@googlegroups.com
I posted this on the talk list and didn't get a response. Perhaps
this is a more appropriate list:

I'm having a problem with rails 2.3.2, engines, and eager loading.
There is a default set of eager_load_paths (the usual suspects under
app/) that will be greedily required by rails at boot time when you're
running with threadsafe! (cache_classes) on, and of course you can
append your own
custom paths. However, so far as I can tell, engines are never
eagerly loaded and therefore unavailable when the system is running in
threadsafe! mode.

First, I'd like to know if I'm missing something. I looked through
the plugin loader, found the code that loads the engines, and could
not discover how, if at all, it attempts to eager load them. I also
explored the rails initializer in railties, found the eager loading
code, and didn't see anything related to plugins there.

So far as workarounds go it appears subclassing the plugin loader is
the best option. I've attached a working loader the end of this message.

Your help is greatly appreciated

regards,

-Tyler Jennings

> lib/eager_loader.rb:

class EagerLoader < Rails::Plugin::Loader
def add_plugin_load_paths
super
engines.each do |engine|
if configuration.cache_classes
configuration.eager_load_paths += engine.load_paths
end
end
end
end

> config/environment.rb:

require File.join(File.dirname(__FILE__), '..', 'lib', 'eager_loader')
...
config.plugin_loader = EagerLoader

Michael Koziarski

unread,
Aug 1, 2009, 4:21:54 AM8/1/09
to rubyonra...@googlegroups.com
> So far as workarounds go it appears subclassing the plugin loader is
> the best option.  I've attached a working loader the end of this message.

I'd be interested in a patch which implements this in general.

Another (related) issue is that engine controllers aren't put on the
reloading paths, meaning you get weird errors if you subclass
ApplicationController in a plugin.

Fixing both of these seems like the right thing to do.


--
Cheers

Koz

Reply all
Reply to author
Forward
0 new messages