我有一个使用mysql的rails项目(并且过去非常成功)。然而,升级我的 postgres 安装后,这个 Rails 项目抛出了适配器未安装错误:
/Users/stuartnelson/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem': Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) (LoadError)
我的database.yml
文件正确地将适配器声明为mysql2
。
我尝试按照建议安装 activerecord-postgresql-adapter gem(但没有将其添加到我的 gemfile 中,因为我没有使用 postgres),但这并没有解决问题。
我仍然能够登录到我的计算机上的 mysql 服务器并验证数据库及其表是否存在。
堆栈跟踪确实显示 Rails 正在尝试使用 postgres 适配器,但我没有在项目中的任何位置指示使用 postgres。
from /Users/stuartnelson/.rvm/gems/ruby-1.9.3-p448@mfacs/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:7:in `<top (required)>'
from /Users/stuartnelson/.rvm/gems/ruby-1.9.3-p448@mfacs/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
from /Users/stuartnelson/.rvm/gems/ruby-1.9.3-p448@mfacs/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/stuartnelson/.rvm/gems/ruby-1.9.3-p448@mfacs/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/stuartnelson/.rvm/gems/ruby-1.9.3-p448@mfacs/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
不知何故,我的 postgres 安装引起了这个(我认为)。有谁有这方面的经验以及如何解决它吗?
最佳答案
当您将 postgresql
作为应用的 config/database.yml
中数据库配置的适配器,并且没有 pg
gem 已安装。
关于mysql - Rails 错误地提示将 postgres 添加到 bundle 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19982423/