vadviktor
9/4/2015 - 9:39 AM

Rails connection pool management with test

Rails connection pool management with test

def safely
  begin
    unless ActiveRecord::Base.connected?
      ActiveRecord::Base.connection.verify!(0)
    end
    yield
  rescue => e
    status e.inspect
  ensure
    ActiveRecord::Base.connection_pool.release_connection
  end
end