Move observers initialization to after_config blocks, they are still being initialized to early (before load paths are being set).

This commit is contained in:
José Valim 2010-04-20 13:44:49 +02:00
parent 9934738ed5
commit 2e3d903e1b

@ -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