Refresh ActiveRecord connection on each rack request
Add the following to your Gemfile
:
gem 'activerecord-refresh_connection'
And then execute:
$ bundle
This gem provides a rack middleware ActiveRecord::ConnectionAdapters::RefreshConnectionManagement
which disconnects all connections in each rack request, which results in refreshing all connections in each rack request.
Swap the default rails ConnectionManagement.
# config/application.rb
require 'activerecord-refresh_connection'
class Application < Rails::Application
config.autoload_paths += %W(#{config.root}/lib)
config.middleware.swap ActiveRecord::ConnectionAdapters::ConnectionManagement,
"ActiveRecord::ConnectionAdapters::RefreshConnectionManagement"
end
Middleware check.
bundle exec rake middleware
To Be Written
See CHANGELOG.md for details.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright (c) 2014 Naotoshi Seo. See LICENSE.txt for details.