ruby-on-rails - 升级到ActiveRecord::ConnectionNotEstablished错误

标签 ruby-on-rails activerecord sqlite

我试图将现有项目从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:in retrieve_connection'
activerecord(4.1.4)lib / active_record / connection_handling.rb:87:在connection' activerecord (4.1.4) lib/active_record/query_cache.rb:51:in restore_query_cache_settings'中
activerecord(4.1.4)lib / active_record / query_cache.rb:43:在rescue in call' activerecord (4.1.4) lib/active_record/query_cache.rb:32:in调用中
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:in阻止通话”
activesupport(4.1.4)lib / active_support / callbacks.rb:82:在`run_callbacks'(1.5.2)中


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

最佳答案

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

rake rails:update


Upgrading to rails 4.0 from 3.2

关于ruby-on-rails - 升级到ActiveRecord::ConnectionNotEstablished错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24858300/

相关文章:

android - 如果 ListView 中有另一个相同的单词,则只显示一个单词

java - 存储为字符串的 Android SQL Lite int 值在检索时显示额外字符

ruby-on-rails - ActiveAdmine register_page 和 Controller

html - 如何将内联 css 添加到 rails link_to helper

mysql - 在 SQLite (RoR) 上使用 mySQL 的好处等

android - 从 ListView 中删除自定义 ListView 中的项目,单击按钮

ruby-on-rails - will_paginate 报告太多条目和页面

ruby-on-rails - ActiveRecord 查询(包含或加入)

sql - 如何根据 ActiveRecord 中的条件在每第 n 个项目中插入?

mysql - 将 ActiveRecord MySQL 查询输出到页面