commit 4d7bbf81aa013d445a8ebf857d3ec60da4f61c04
Author: Karel Minarik <karmi@karmi.cz>
Date: Mon Aug 17 12:29:41 2009 +0200
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
\ No newline at end of file
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 85c9a60..81ad49d 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -14,4 +14,9 @@ config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
-config.action_mailer.raise_delivery_errors = false
\ No newline at end of file
+config.action_mailer.raise_delivery_errors = false
+
+# THIS DOES NOT MAKE A DIFFERENCE, must be in environment.rb
+# Reload plugins, see http://github.com/rails/rails/blob/2-3-stable/railties/lib/initializer.rb#L763-779
+# config.reload_plugins = true
+# ActiveSupport::Dependencies.load_once_paths.delete Rails.root.join('vendor/plugins/friendly_message/lib')
\ No newline at end of file