Make extension objects reload between requests

Are Radiant custom extension controllers, models, etc. supposed to
reload between each request like regular Rails objects in development
mode or not?

I thought they did, but I’m not seeing mine reload.

Thanks,
Wes

On Oct 24, 2010, at 5:24 PM, Wes G. wrote:

Are Radiant custom extension controllers, models, etc. supposed to reload
between each request like regular Rails objects in development mode or not?

Rails sees Radiant extensions as plugins, not engines or native
application entities. They won’t get reloaded unless you take steps to
make it happen. If you take a look at the PageFactory extension, I’m
doing something along those lines:

Dir["#{path}/*_page_factory.rb"].each do |page_factory|
if page_factory =~ %r{/([^/]+).rb}
require_dependency page_factory
ActiveSupport::Dependencies.explicitly_unloadable_constants <<
$1.camelize
end
end

I’m 1) registering my own classes with ActiveSupport’s dependency
mechanism, and 2) telling ActiveSupport that these need to get reloaded
between requests.

Hope that helps,
j

I’m a novice at extension authoring, but in my experience the code
gets reloaded every second refresh. No explanation why that’d be
(Chrome + 0.9.1 + Mongrel), but it works for me.

  • Jeff