/*
PLUGIN RELOADING IMPLEMENTATION
1. We need to set "config.reload_plugins" in environment.rb, it makes no difference in development.rb
2. We must delete plugin's "lib" folder from ActiveSupport::Dependencies.load_once_paths
3. We must reload plugin's "init.rb" in controller (using before_filter)
*/
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 6635a3f..f5ebf8e 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -7,4 +7,13 @@ class ApplicationController < ActionController::Base
# Scrub sensitive parameters from your log
# filter_parameter_logging :password
+
+ before_filter :reload_plugin
+
+ private
+
+ # Force-load plugins init.rb file to include it's module Again
+ def reload_plugin
+ ActiveSupport::Dependencies.load_file Rails.root.join('vendor/plugins/friendly_message/init.rb').to_s
+ end
end
diff --git a/config/environment.rb b/config/environment.rb
index 685505d..19585c1 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -38,4 +38,9 @@ Rails::Initializer.run do |config|
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de
+
+ # Reload plugins, see http://github.com/rails/rails/blob/2-3-stable/railties/lib/initializer.rb#L763-779
+ config.reload_plugins = true
+ # Exclude plugin from paths loading only once
+ ActiveSupport::Dependencies.load_once_paths.delete Rails.root.join('vendor/plugins/friendly_message/lib')
end