“没有加载postgresql gem”错误在Heroku上部署Ruby on Rails应用程序
我试图在Heroku 上使用带Ruby on Rails的 postgresql但是出错了
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上部署。
如果您想在所有环境中使用PostgreSQL而不仅仅是在production
环境中(推荐),请在:production
group之外添加gem,并删除其他数据库适配器,例如sqlite
。
作为旁注,您可能还想按照Heroku的建议添加rails_12factor
gem。
这对我有用
gem 'pg', '~> 0.20'
感谢Piers C.
得到了这个答案
Heroku和Rails:Postgres的Gem加载错误,但它在GEMFILE中指定
在gemfile中添加pg
gem 'pg', '~> 0.20'
然后捆绑更新并将Gemfile和Gemfile.lock提交到heroku。
简单包括像gem’pg’将无法正常工作。