ruby-on-rails - Rails 和 postgres - 在 heroku 上部署期间忽略 pg gem

标签 ruby-on-rails postgresql heroku

我在 heroku 上部署我的应用程序时遇到问题。我已将“pg”gem 添加到 Gemfile,甚至尝试包含诸如 gem“therubyracer-heroku”之类的内容。 期间

heroku rake db:migrate

我得到这样的东西:

>heroku rake db:migrate
 --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adap
ter` (pg is not part of the bundle. Add it to Gemfile.)
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/connectio
n_adapters/abstract/connection_specification.rb:71:in `rescue in establish_conne
ction'

另一个有趣的部分是,在捆绑安装操作期间没有提到推送到 heroku pg,就像它被忽略一样。我还观看了 Gemfile.lock,其中提到了 pg:

pg (0.11.0-x86-mingw32)

我想知道是否是导致 heroku 忽略 pg gem 的 Windows gem 问题?

任何人都可以帮助或有类似的问题吗?

//编辑

似乎相关:enter link description here

看起来无法解决

最佳答案

在你的 Gemfile 中限制 postgres 到你的生产组;

group :production do
  gem "pg"
end

再捆绑

bundle --without production

并提交到 git(Gemfile 和 Gemfile.lock)并推送到 Heroku。那应该可以解决您的问题。

关于ruby-on-rails - Rails 和 postgres - 在 heroku 上部署期间忽略 pg gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7822896/

相关文章:

ruby-on-rails - rails : Rendering Partials through Ajax with Buttons

node.js - 无法从 Node 服务器连接到 postgres 数据库

mysql - PostgreSQL 在 mySQL 中的 date_trunc

mysql - 名称错误 : name 'DATABASES' is not defined with AWS RDS

python - 在 Heroku 上发送 Django 电子邮件

ruby-on-rails - 您可以在elastic beanstalk环境中运行rails控制台或rake命令吗?

javascript - 通过命名函数避免 CoffeeScript 中的重复代码

ruby-on-rails - marshal 数据太短

postgresql - seam 文件上传到 postgres bytea 列 "column is bytea but expression is of type bigint"

python - Heroku 无法满足要求 tensorflow==2.3.0