与Sinatra的ActiveRecord :: ConnectionTimeoutError

时间:2013-12-30 18:02:34

标签: ruby activerecord sinatra

我正在开发一个带有ActiveRecord和SQLite的模块化Sinatra应用程序。超过连接池大小后,我继续遇到ActiveRecord::ConnectionTimeoutError could not obtain a database connection within 5.000 seconds (waited 5.001 seconds)

我尝试了以下所有方法:

    来自here
  1. use ActiveRecord::ConnectionAdapater::ConnectionManagement 来自here
  2. after { ActiveRecord::Base.connection.close } 来自here
  3. 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
    

0 个答案:

没有答案