Written by Sean Behan on Sat Nov 09th 2013

If you get this error message

ActiveRecord::ConnectionTimeoutError could not obtain a database connection within 5.000 seconds (waited 5.001 seconds)

Try closing the connection after each request using "after" in Sintara.

# app.rb

after { ActiveRecord::Base.connection.close }

get '/' do
    erb :index
end

The after block will get called after each request and close your database connection.


Tagged with..
#Sinatra #Ruby #Databases #ActiveRecord #Errors

Just finishing up brewing up some fresh ground comments...