From 26eefd79a4e9afefb3103d8332a1e7dc84ed49a1 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Sun, 6 Aug 2006 02:12:53 +0000 Subject: 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 --- railties/CHANGELOG | 2 ++ railties/lib/dispatcher.rb | 2 +- railties/lib/initializer.rb | 11 +++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'railties') 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 :active_record # is one of the frameworks to load (Configuration#frameworks). If it is, # this sets the database configuration from Configuration#database_configuration -- cgit v1.2.3