I am running a modular Sinatra app with ActiveRecord with SQLite on development. I keep on running into ActiveRecord::ConnectionTimeoutError could not obtain a database connection within 5.000 seconds (waited 5.001 seconds)
after exceeding my connection pool size.
I have tried all the following methods:
use ActiveRecord::ConnectionAdapater::ConnectionManagement
from hereafter { ActiveRecord::Base.connection.close }
from hereActiveRecord::Base.clear_active_connections!
from here
However, I still keep on getting the same errors!
# 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