提交 2e3d903e 编写于 作者: J José Valim

Move observers initialization to after_config blocks, they are still being...

Move observers initialization to after_config blocks, they are still being initialized to early (before load paths are being set).
上级 9934738e
...@@ -70,27 +70,23 @@ class Railtie < Rails::Railtie ...@@ -70,27 +70,23 @@ class Railtie < Rails::Railtie
end end
end end
initializer "active_record.add_observer_hook", :after=>"active_record.set_configs" 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
ActionDispatch::Callbacks.to_prepare(:activerecord_instantiate_observers) do unless app.config.cache_classes
ActiveRecord::Base.instantiate_observers ActionDispatch::Callbacks.after do
ActiveRecord::Base.reset_subclasses
ActiveRecord::Base.clear_reloadable_connections!
end
end end
end end
end end
initializer "active_record.instantiate_observers", :after=>"active_record.initialize_database" do config.after_initialize do
ActiveSupport.on_load(:active_record) do ActiveSupport.on_load(:active_record) do
instantiate_observers instantiate_observers
end
end
initializer "active_record.set_dispatch_hooks", :before => :set_clear_dependencies_hook do |app| ActionDispatch::Callbacks.to_prepare(:activerecord_instantiate_observers) do
ActiveSupport.on_load(:active_record) do ActiveRecord::Base.instantiate_observers
unless app.config.cache_classes
ActionDispatch::Callbacks.after do
ActiveRecord::Base.reset_subclasses
ActiveRecord::Base.clear_reloadable_connections!
end
end end
end end
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册