ActiveRecord connection warning. (Database connections will not be closed automatically)

前端 未结 3 1905
天涯浪人
天涯浪人 2020-12-16 18:50

I\'m trying to create a little app with Sinatra and ActiveRecord (3.2.3).

This is how my main file looks like:

require \"sinatra\"
require \"sinatra/         


        
相关标签:
3条回答
  • 2020-12-16 19:36

    You need to add a middleware to your stack. Just add this line to your config.ru rack up file:

    use ActiveRecord::ConnectionAdapters::ConnectionManagement
    

    Found the answer here: https://github.com/puma/puma/issues/59

    0 讨论(0)
  • 2020-12-16 19:44
    ActiveRecord::Base.remove_connection
    

    Works fine for me and is listed in the docs.

    0 讨论(0)
  • 2020-12-16 19:50

    The accepted answer did not work for me in Sinatra on Thin (threaded mode). Instead I used:

    after do
      ActiveRecord::Base.connection.close
    end
    
    0 讨论(0)
提交回复
热议问题