diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index 878a4dac09..f3d21d4969 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -70,20 +70,6 @@ class Railtie < Rails::Railtie end end - 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 - end - 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 @@ -94,5 +80,15 @@ class Railtie < Rails::Railtie end end end + + config.after_initialize do + ActiveSupport.on_load(:active_record) do + instantiate_observers + + ActionDispatch::Callbacks.to_prepare(:activerecord_instantiate_observers) do + ActiveRecord::Base.instantiate_observers + end + end + end end end