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
Written by Rafael Felix
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Active record
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#