“未加载 postgresql gem"在 Heroku 上部署 Ruby on Rails 应用程序时出错 [英] "postgresql gem is not loaded" error deploying a Ruby on Rails application on Heroku
问题描述
我正在尝试在 Heroku 上将 postgresql 与 Ruby on Rails 结合使用,但出现错误
I am trying to use postgresql with Ruby on Rails on Heroku but got an error
Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
请帮我解决这个问题.
推荐答案
在你的 Gemfile
group :production do
gem 'pg'
end
然后运行 bundle install
并尝试在 Heroku 上部署.
Then run bundle install
and try to deploy on Heroku.
如果您想在所有环境中使用 PostgreSQL 而不仅仅是在 production
(推荐)中,请在 :production
组之外添加 gem 并删除其他数据库适配器,例如 <代码>sqlite.
If you want to use PostgreSQL on all environments and not only in production
(recommended) add the gem outside the :production
group and remove other database adapters such as sqlite
.
作为旁注,您可能还想添加 rails_12factor
Heroku 建议的 gem.
As a side note, you may also want to add the rails_12factor
gem as suggested by Heroku.
这篇关于“未加载 postgresql gem"在 Heroku 上部署 Ruby on Rails 应用程序时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!