我正在开发一个带有ActiveRecord和SQLite的模块化Sinatra应用程序。超过连接池大小后,我继续遇到ActiveRecord::ConnectionTimeoutError could not obtain a database connection within 5.000 seconds (waited 5.001 seconds)
。
我尝试了以下所有方法:
use ActiveRecord::ConnectionAdapater::ConnectionManagement
来自here after { ActiveRecord::Base.connection.close }
来自here ActiveRecord::Base.clear_active_connections!
醇>
然而,我仍然继续犯同样的错误!
# Gemfile
source 'https://rubygems.org'
ruby '2.0.0'
gem 'activerecord', '~> 4.0.2'
gem 'sass', '~> 3.2.12'
gem 'sinatra', '~> 1.4.4'
gem 'sinatra-activerecord'
gem 'sinatra-assetpack', '~> 0.3.1'
gem 'sinatra-contrib', '~> 1.4.2'
gem 'slim', '~> 2.0.2'
group :development do
gem 'tux'
gem 'sqlite3'
end
group :production do
gem 'pg'
end
group :test do
gem 'database_cleaner'
gem 'factory_girl', '~> 4.3.0'
gem 'rspec'
end
# environments.rb
config :development do
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: 'local.db'
)
end