mysql - Rails 错误地提示将 postgres 添加到 bundle 中

标签 mysql ruby-on-rails postgresql

我有一个使用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/

相关文章:

ruby-on-rails - 如何使用Docker安装Guard-Test?

ruby-on-rails - ActiveAdmin Rails 编辑/删除

postgresql - PGbouncer 错误 accept() 失败 : Too many open files

sql - 从另一个表和静态值更新 SQL 行

postgresql - SQL 工作台 + PostgreSQL : how to show execution plans?

c# - 在 c# 面板上使用 DataReader 和 TextBox 控件的 Repeater 控件

mysql - MySQL根据年份条件查询

MySQL where if 语句

ruby-on-rails - 检查延迟作业是否在 rails 中运行

php - mysql_connect() 在本地主机上工作正常,但在访问单独的 ip 时却不行