class ActiveRecord::ConnectionAdapters::ConnectionManagement

def call(env)

def call(env)
  testing = env.key?('rack.test')
  response = @app.call(env)
  response[2] = ::Rack::BodyProxy.new(response[2]) do
    ActiveRecord::Base.clear_active_connections! unless testing
  end
  response
rescue
  ActiveRecord::Base.clear_active_connections! unless testing
  raise
end

def initialize(app)

def initialize(app)
  @app = app
end