ActiveRecord middlewares should be inserted before AD::Cascade [#4493 state:resolved].

This commit is contained in:
José Valim 2010-04-29 13:24:24 +02:00
parent e9a9ef094e
commit 3dfcb56e45
3 changed files with 6 additions and 11 deletions

View File

@ -61,13 +61,8 @@ module ActiveRecord
# Setup database middleware after initializers have run
initializer "active_record.initialize_database_middleware", :after => "action_controller.set_configs" do |app|
middleware = app.config.middleware
if middleware.include?("ActiveRecord::SessionStore")
middleware.insert_before "ActiveRecord::SessionStore", ActiveRecord::ConnectionAdapters::ConnectionManagement
middleware.insert_before "ActiveRecord::SessionStore", ActiveRecord::QueryCache
else
middleware.use ActiveRecord::ConnectionAdapters::ConnectionManagement
middleware.use ActiveRecord::QueryCache
end
middleware.insert_after "::ActionDispatch::Callbacks", ActiveRecord::QueryCache
middleware.insert_after "::ActionDispatch::Callbacks", ActiveRecord::ConnectionAdapters::ConnectionManagement
end
initializer "active_record.set_dispatch_hooks", :before => :set_clear_dependencies_hook do |app|

View File

@ -143,7 +143,7 @@ module Rails
middleware.use('::Rack::Runtime')
middleware.use('::Rails::Rack::Logger')
middleware.use('::ActionDispatch::ShowExceptions', lambda { consider_all_requests_local }, :if => lambda { action_dispatch.show_exceptions })
middleware.use("::ActionDispatch::RemoteIp", lambda { action_dispatch.ip_spoofing_check }, lambda { action_dispatch.trusted_proxies })
middleware.use('::ActionDispatch::RemoteIp', lambda { action_dispatch.ip_spoofing_check }, lambda { action_dispatch.trusted_proxies })
middleware.use('::Rack::Sendfile', lambda { action_dispatch.x_sendfile_header })
middleware.use('::ActionDispatch::Callbacks', lambda { !cache_classes })
middleware.use('::ActionDispatch::Cookies')

View File

@ -27,14 +27,14 @@ module ApplicationTests
"ActionDispatch::RemoteIp",
"Rack::Sendfile",
"ActionDispatch::Callbacks",
"ActiveRecord::ConnectionAdapters::ConnectionManagement",
"ActiveRecord::QueryCache",
"ActionDispatch::Cookies",
"ActionDispatch::Session::CookieStore",
"ActionDispatch::Flash",
"ActionDispatch::ParamsParser",
"Rack::MethodOverride",
"ActionDispatch::Head",
"ActiveRecord::ConnectionAdapters::ConnectionManagement",
"ActiveRecord::QueryCache"
"ActionDispatch::Head"
], middleware
end