ft9drq
Last Updated: February 25, 2016
·
1.672K
· fellix
A70aa5d32b9c30f1f9c94d0ae47093ac

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
Say Thanks
Respond