我试图在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)
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题.
在你的 Gemfile
group :production do
gem 'pg'
end
Run Code Online (Sandbox Code Playgroud)
然后运行bundle install
并尝试在Heroku上部署.
如果您想在所有环境中使用PostgreSQL,而不仅仅是production
(推荐)在:production
组外添加gem 并删除其他数据库适配器,例如sqlite
.
作为旁注,您可能还想rails_12factor
按照Heroku的建议添加gem.
在gemfile中添加pg
gem 'pg', '~> 0.20'
Run Code Online (Sandbox Code Playgroud)
然后捆绑更新并将Gemfile和Gemfile.lock提交给heroku.
简单包括像宝石'pg'将无法正常工作.