aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-08-06 02:12:53 +0000
committerRick Olson <technoweenie@gmail.com>2006-08-06 02:12:53 +0000
commit26eefd79a4e9afefb3103d8332a1e7dc84ed49a1 (patch)
tree4acea9d663f3b82a67f90b4d82f3330ff07b50b0
parente8f0b1ddd97cfcefc32554a1a9447ec092c4d0ae (diff)
downloadrails-26eefd79a4e9afefb3103d8332a1e7dc84ed49a1.tar.gz
rails-26eefd79a4e9afefb3103d8332a1e7dc84ed49a1.tar.bz2
rails-26eefd79a4e9afefb3103d8332a1e7dc84ed49a1.zip
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
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/dispatcher.rb2
-rw-r--r--railties/lib/initializer.rb11
3 files changed, 12 insertions, 3 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 098e4b317a..63f3197fcd 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -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]
diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb
index f4cb52b3b7..32f286434f 100644
--- a/railties/lib/dispatcher.rb
+++ b/railties/lib/dispatcher.rb
@@ -54,7 +54,7 @@ class Dispatcher
# 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
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 16f213bc16..de58051f97 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -67,6 +67,7 @@ module Rails
# * #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 @@ module Rails
initialize_breakpoints
initialize_whiny_nils
initialize_temporary_directories
-
initialize_framework_settings
# Support for legacy configuration style where the environment
@@ -100,6 +100,9 @@ module Rails
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 @@ module Rails
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