I am trying to have a plugin I am developing auto-reload every time I change my code, emulating the same auto-reloading that happens normally in Rail's development mode. My plugin is primarily an ActiveRecord mixin module. I have tried all suggestions I have been able to find in related Google searches. Nothing has worked yet.
In my plugin's init.rb:
require 'activesupport' unless defined? ActiveSupport
require 'activerecord' unless defined? ActiveRecord
if RAILS_ENV == 'development'
ActiveSupport::Dependencies.load_once_paths.delete lib_path
ActiveSupport::Dependencies.load_once_paths.delete File.join(lib_path, 'crowd_compass', 'publisher.rb')
ActiveSupport::Dependencies.load_paths << lib_path
ActiveSupport::Dependencies.load_paths << File.join(lib_path, 'crowd_compass', 'publisher.rb')
end
ActiveRecord::Base.send(:include, CrowdCompass::Publisher)
Looking in the rails changelog, I did notice the feature to auto reload all plugins.
config.reload_plugins = true if RAILS_ENV == 'development'
This did not work as I expected it to when I added it to my conf/environment.rb
My plugin is structured so all files are auto-loaded by namespace => directory. I did this so I could avoid using "require", as I thought require was inhibiting my plugin from being auto-reloaded.
I have been doing all of my work in development mode through the rails console and I do not know if this behaves any different than running through mongrel (or like web server).
The plugin works as expected, but I have to reload every time I make any change to the code. Does anyone know a way to get plugins to reload?