Class: ActiveRecord::Rack::ConnectionManagement

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/rack/connection_management.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ConnectionManagement

Returns a new instance of ConnectionManagement.



26
27
28
# File 'lib/active_record/rack/connection_management.rb', line 26

def initialize(app)
	@app = app
end

Instance Method Details

#call(env) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/active_record/rack/connection_management.rb', line 30

def call(env)
	response = @app.call(env)
	
	response[2] = ::Rack::BodyProxy.new(response[2]) do
		ActiveRecord::Base.clear_active_connections!
	end
	
	return response
rescue Exception
	ActiveRecord::Base.clear_active_connections!
	raise
end