1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Split the observer railtie into two phases.

Observers observing models with scopes defined will require the connection to be established.
This commit is contained in:
Michael Koziarski 2010-04-16 09:47:11 +12:00
parent 0ea434e2f4
commit 5aa58cc03f

View file

@ -70,9 +70,7 @@ module ActiveRecord
end end
end end
initializer "active_record.load_observers" do initializer "active_record.add_observer_hook", :after=>"active_record.set_configs" do |app|
ActiveSupport.on_load(:active_record) { instantiate_observers }
ActiveSupport.on_load(:active_record) do ActiveSupport.on_load(:active_record) do
ActionDispatch::Callbacks.to_prepare(:activerecord_instantiate_observers) do ActionDispatch::Callbacks.to_prepare(:activerecord_instantiate_observers) do
ActiveRecord::Base.instantiate_observers ActiveRecord::Base.instantiate_observers
@ -80,6 +78,12 @@ module ActiveRecord
end 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| initializer "active_record.set_dispatch_hooks", :before => :set_clear_dependencies_hook do |app|
ActiveSupport.on_load(:active_record) do ActiveSupport.on_load(:active_record) do
unless app.config.cache_classes unless app.config.cache_classes