Permalink
Browse files

ActiveRecord middlewares should be inserted before AD::Cascade [#4493

…state:resolved].
  • Loading branch information...
josevalim committed Apr 29, 2010
1 parent e9a9ef0 commit 3dfcb56e4585c8530be6dcc5129ae0c4d16c0dea
@@ -61,13 +61,8 @@ class Railtie < Rails::Railtie
# 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|
@@ -143,7 +143,7 @@ def default_middleware_stack
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')
@@ -27,14 +27,14 @@ def app
"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

0 comments on commit 3dfcb56

Please sign in to comment.