【问题标题】:ActiveRecord::ConnectionNotEstablished error when upgrading to升级到 ActiveRecord::ConnectionNotEstablished 错误
【发布时间】:2014-09-11 13:22:18
【问题描述】:

我尝试将现有项目从 Rails 3.2.3 升级到 Rails 4.1.4(最新)。我更新了我的 gemfile,更新包没有问题。我也加了

config.eager_load = false

到我的环境 *.rb。当我运行服务器时,当我尝试访问第一页时出现以下错误……看起来没有连接到数据库,但我可以使用客户端访问它。我的服务目前使用 sqlite3..

ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished): activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in retrieve_connection' activerecord (4.1.4) lib/active_record/connection_handling.rb:113:inretrieve_connection' activerecord (4.1.4) lib/active_record/connection_handling.rb:87:in connection' activerecord (4.1.4) lib/active_record/query_cache.rb:51:inrestore_query_cache_settings' activerecord (4.1.4) lib/active_record/query_cache.rb:43:in rescue in call' activerecord (4.1.4) lib/active_record/query_cache.rb:32:incall' activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in call' actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call' activesupport (4.1.4) lib/active_support/callbacks.rb:82:in `run_callbacks' (1.5.2) li

b/rack/runtime.rb:17:in `call' …

我的 database.yml 文件没有改变。它使用 sqlite3

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

【问题讨论】:

    标签: ruby-on-rails activerecord sqlite


    【解决方案1】:

    事实证明,当从 3.2 迁移到 4.0 时,需要对配置文件进行很多更改。您可以在下面的链接中查看详细信息,我能够使用 postgres 而不是 sqlite 解决问题并运行链接建议的命令

    rake rails:update
    

    Upgrading to rails 4.0 from 3.2

    【讨论】:

      猜你喜欢
      • 2012-04-05
      • 2011-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多