Ruby on rails &引用;postgresql gem未加载";在Heroku上部署Ruby on Rails应用程序时出错
我试图在Heroku上使用postgresql和RubyonRails,但出现了一个错误Ruby on rails &引用;postgresql gem未加载";在Heroku上部署Ruby on Rails应用程序时出错,ruby-on-rails,Ruby On Rails,我试图在Heroku上使用postgresql和RubyonRails,但出现了一个错误 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) 请帮我解决这个问题。在您的ge
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)
请帮我解决这个问题。在您的
gem文件中
group :production do
gem 'pg'
end
然后运行bundle install
并尝试在Heroku上部署
如果您希望在所有环境中使用PostgreSQL,而不仅仅是在生产环境中使用PostgreSQL(推荐),请在:production
组之外添加gem,并删除其他数据库适配器,如sqlite
作为补充说明,您可能还希望按照Heroku的建议添加宝石。这对我来说很有效
gem'pg','~>0.20'
多亏了皮尔斯C
我从你那里得到了这个答案
在文件中添加pg
gem 'pg', '~> 0.20'
然后将更新和提交Gemfile&Gemfile.lock捆绑到heroku。
像gem'pg'这样的简单include将不起作用。我在我的gem文件中添加了以下版本,它已经解决了
gem“pg”、“~>0.18”
请添加您的Gemfile
和database.yml
文件。Heroku仅支持postgresql
FYI。添加pg gem并运行bundle安装…然后使用Heroku运行rake db:migrate安装数据库Heroku选择postgresql而不是MySQL的原因是什么?请参考此链接,简单地将gem“pg”添加到gem文件对我来说不起作用。似乎是版本问题。非常感谢,在执行捆绑包更新后,还要提交gemfile.lock