Permalink
Browse files

Tweak the Rails load order so observers are loaded after plugins, and…

… reloaded in development mode. Closed #5279.  [Rick Olson]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4684 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent e8f0b1d commit 26eefd79a4e9afefb3103d8332a1e7dc84ed49a1 @technoweenie technoweenie committed Aug 6, 2006
Showing with 12 additions and 3 deletions.
  1. +2 −0 railties/CHANGELOG
  2. +1 −1 railties/lib/dispatcher.rb
  3. +9 −2 railties/lib/initializer.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Tweak the Rails load order so observers are loaded after plugins, and reloaded in development mode. Closed #5279. [Rick Olson]
+
* Added that you can change the web server port in config/lighttpd.conf from script/server --port/-p #5465 [mats@imediatec.co.uk]
* script/performance/profiler compatibility with the new ruby-prof, including an option to choose the results printer. #5679 [shugo@ruby-lang.org]
@@ -54,7 +54,7 @@ def dispatch(cgi = nil, session_options = ActionController::CgiRequest::DEFAULT_
# to restart the server (WEBrick, FastCGI, etc.).
def reset_application!
Dependencies.clear
- ActiveRecord::Base.reset_subclasses
+ ActiveRecord::Base.reset
Class.remove_class(*Reloadable.reloadable_classes)
end
@@ -67,6 +67,7 @@ def initialize(configuration)
# * #initialize_framework_settings
# * #load_environment
# * #load_plugins
+ # * #load_observers
# * #initialize_routing
#
# (Note that #load_environment is invoked twice, once at the start and
@@ -89,7 +90,6 @@ def process
initialize_breakpoints
initialize_whiny_nils
initialize_temporary_directories
-
initialize_framework_settings
# Support for legacy configuration style where the environment
@@ -100,6 +100,9 @@ def process
add_support_load_paths
load_plugins
+
+ # Observers are loaded after plugins in case Observers or observed models are modified by plugins.
+ load_observers
# Routing must be initialized after plugins to allow the former to extend the routes
initialize_routing
@@ -171,7 +174,11 @@ def load_environment
end
end
end
-
+
+ def load_observers
+ ActiveRecord::Base.instantiate_observers
+ end
+
# This initialization routine does nothing unless <tt>:active_record</tt>
# is one of the frameworks to load (Configuration#frameworks). If it is,
# this sets the database configuration from Configuration#database_configuration

0 comments on commit 26eefd7

Please sign in to comment.