diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-02-24 11:34:32 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-02-24 11:34:32 -0600 |
commit | 1b22071b276a2a2b3e65e6db40c6a0aa92d9ebc3 (patch) | |
tree | 240347e78d8877a4e98ea9fdda82f5c57428b620 /railties | |
parent | d32eb410f19f6872df1e1e1810840c0f5aa13b50 (diff) | |
download | rails-1b22071b276a2a2b3e65e6db40c6a0aa92d9ebc3.tar.gz rails-1b22071b276a2a2b3e65e6db40c6a0aa92d9ebc3.tar.bz2 rails-1b22071b276a2a2b3e65e6db40c6a0aa92d9ebc3.zip |
Ensure ActiveRecord session store's connections are checked in after each request [#1927 state:resolved]
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/initializer.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index a31ae9422e..09affe9e36 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -176,6 +176,9 @@ module Rails # the framework is now fully initialized after_initialize + # Setup database middleware after initializers have run + initialize_database_middleware + # Prepare dispatcher callbacks and run 'prepare' callbacks prepare_dispatcher @@ -410,7 +413,18 @@ Run `rake gems:install` to install the missing gems. if configuration.frameworks.include?(:active_record) ActiveRecord::Base.configurations = configuration.database_configuration ActiveRecord::Base.establish_connection - configuration.middleware.use ActiveRecord::QueryCache + end + end + + def initialize_database_middleware + if configuration.frameworks.include?(:active_record) + if ActionController::Base.session_store == ActiveRecord::SessionStore + configuration.middleware.insert_before :"ActiveRecord::SessionStore", ActiveRecord::ConnectionAdapters::ConnectionManagement + configuration.middleware.insert_before :"ActiveRecord::SessionStore", ActiveRecord::QueryCache + else + configuration.middleware.use ActiveRecord::ConnectionAdapters::ConnectionManagement + configuration.middleware.use ActiveRecord::QueryCache + end end end |