Reload Everything (lib/plugins/vendor/the lot)

Is there a way to reload everything on each request. I'm working with a lot of lib and vendor/plugin files, and in development mode i'd like to have all of those reloaded.

I used to have a couple of methods that worked in rails < 2.1 but they are no longer working.

Is there a way to reload everything on each request. I'm working with a lot of lib and vendor/plugin files, and in development mode i'd like to have all of those reloaded.

I used to have a couple of methods that worked in rails < 2.1 but they are no longer working.

I wrote up what I do at Reload me, Reload me not - Space Vatican

Fred

Whatever I do I still can not reload the plugin, the plugin is definitely not in the load once paths. My init.rb just contains 4 requires but nothing besides that.

I've googled, nobody else seems to be having this issue.

config.reload_plugins = true; deletes all of the Dependencies.load_paths, but the plugin still doesn't reload

I ran into the same problem; turned out that I also had to add the module which contains my plugin's classes to ActiveSupport::Dependencies.explicitly_unloadable_constants

So if you have your plugin structured like this

init.rb lib/myplugin.rb lib/myplugin/*.rb

you should add the following line to your init.rb

ActiveSupport::Dependencies.explicitly_unloadable_constants = 'Myplugin'

and then declare a module (or a class) called Myplugin in lib/ myplugin.rb (otherwise Rails would give me errors about expecting this file to declare a class with that name)

Ingmar: Thankyou for your reply, I still haven't managed to resolve the issue

My init.rb file contains the following: require 'activeext.rb' require 'activeext_model.rb' require 'activeext_controller.rb' require 'activeext_view.rb'

Dependencies.explicitly_unloadable_constants = 'ActiveExt' Dependencies.load_once_paths.delete(File.expand_path(File.dirname(__FILE__))+'/lib'

For some reason scoping Dependencies in the ActiveSupport module doesn't work. Also after I add the explicitly_unloadable_constants, the module is no longer available in the controller. (I suppose this could be because the plugin has the same name as the module?

Ingmar wrote:

Ingmar: Thankyou for your reply, I still haven't managed to resolve
the issue

My init.rb file contains the following: require 'activeext.rb' require 'activeext_model.rb' require 'activeext_controller.rb' require 'activeext_view.rb'

Dependencies.explicitly_unloadable_constants = 'ActiveExt' Dependencies. load_once_paths.delete(File.expand_path(File.dirname(__FILE__))+'/lib'

For some reason scoping Dependencies in the ActiveSupport module
doesn't work. Also after I add the explicitly_unloadable_constants, the
module is no longer available in the controller. (I suppose this could be because the plugin has the same name as the module?

Dependencies is only inside the activesupport namespace in edge. Even
if a plugin is marked as reloadable it's init.rb won't get reloaded as
far as I know - it just controls whether the constants are removed
after requests

Fred

Alex,

It might be a name-convention issue... If your module/class is called 'ActiveExt' then the corresponding .rb file should be named active_ext.rb (without the underline, it corresponds to the class 'Activeext' without the capital E)

Try to either rename your model or your files accordingly. Make sure that you're running the latest version of Rails (I'm using 2.1.1 atm) which encourages you to use ActiveSupport::Dependencies rather than just Dependencies btw.

You may also create a new project and try it with a non-brainer-plugin first, like a class that only has one method throwing a certain string. You should be able to access that class from within your controller without adding another 'require' command (the one from init.rb should be sufficient).

One more thing (sorry for the verbose reply) - if you're adding functionality to some of Rails' modules and classes like for example ActiveRecord, you might be out of luck. As far as I understand it, these are generally not being reloaded although there may still be some tricks I don't know of.