diff options
author | Michael Koziarski <michael@koziarski.com> | 2010-04-16 09:47:11 +1200 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2010-04-16 09:49:06 +1200 |
commit | 5aa58cc03fa96d290a902e8fd2e6d013bc5d6147 (patch) | |
tree | 382a1665ce898d96162da5f180924f5dad204598 /activerecord/lib | |
parent | 0ea434e2f4083368fe9657aae9ceb5c484336f14 (diff) | |
download | rails-5aa58cc03fa96d290a902e8fd2e6d013bc5d6147.tar.gz rails-5aa58cc03fa96d290a902e8fd2e6d013bc5d6147.tar.bz2 rails-5aa58cc03fa96d290a902e8fd2e6d013bc5d6147.zip |
Split the observer railtie into two phases.
Observers observing models with scopes defined will require the connection to be established.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/railtie.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index 04c4a9c153..878a4dac09 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -70,9 +70,7 @@ module ActiveRecord end end - initializer "active_record.load_observers" do - ActiveSupport.on_load(:active_record) { instantiate_observers } - + initializer "active_record.add_observer_hook", :after=>"active_record.set_configs" do |app| ActiveSupport.on_load(:active_record) do ActionDispatch::Callbacks.to_prepare(:activerecord_instantiate_observers) do ActiveRecord::Base.instantiate_observers @@ -80,6 +78,12 @@ module ActiveRecord end end + initializer "active_record.instantiate_observers", :after=>"active_record.initialize_database" do + ActiveSupport.on_load(:active_record) do + instantiate_observers + end + end + initializer "active_record.set_dispatch_hooks", :before => :set_clear_dependencies_hook do |app| ActiveSupport.on_load(:active_record) do unless app.config.cache_classes |