Last Updated: February 25, 2016
·
1.99K
· fellix

Avoiding ActiveRecord close deprecation warning on Sinatra app

I've a Sinatra application running with ActiveRecord, and after some database iteractions, I've this output on my server log:

  • DEPRECATION WARNING: Database connections will not be closed automatically, please close your database connection at the end of the thread by calling close on your connection. For example: ActiveRecord::Base.connection.close

in order to fix this, just add ActiveRecord middleware to your sinatra application:

class Application < Sinatra::Base
  use ActiveRecord::ConnectionAdapters::ConnectionManagement
end