I been spending a lot of time lately in the land of plugins for Rails. I’m in the process of overhauling a bunch of GUI helpers I wrote a long time ago. One thing that was slowly driving me crazy is that every time I make a change I had to restart the web server to get it to reload everything in development. My old tricks for reloadability just didn’t seem to work.
I had looked for a solution before but came up empty handed. This time I hit pay dirt. Turns out you have to add some small bit of code to you environment.rb and you get reloadability back. Now I can get down to some business.
spotstory ยป Upgrading to Rails 1.2
Ok. I need to reload my plugins. Bleh. Further, this has to happen in environment.rb, not in environments/development.rb. Bleh.
# Array of plugins with Application model dependencies.
reloadable_plugins = ["acts_as_commentable"]
# Force these plugins to reload, avoiding stale object references.
reloadable_plugins.each do |plugin_name|
reloadable_path = RAILS_ROOT “/vendor/plugins/#{plugin_name}/lib”
Dependencies.load_once_paths.delete(reloadable_path)
end
Leave a Reply
Moderation Active: Old stuff here... Therefore your comment on this post will be moderated (i.e. don't submit twice !)