我是Rails的新手.此应用程序在我的本地计算机上正常工作,并且没有任何问题地部署.但是当我运行heroku运行rake db:migrate时,我收到此错误:
Running `rake db:migrate` attached to terminal... up,run.1269 rake aborted! Gem::LoadError: Specified 'postgresql' for database adapter,but the gem is not loaded. Add `gem 'pg'` to your Gemfile.
解决方法
将此行添加到:production group中的Gemfile中(如果没有,请添加一行).
group :production do gem 'pg' gem 'rails_12factor' end
从错误中可以清楚地看出,宝石pg需要添加到你的Gemfile中.您可能只是添加了它,但您需要为开发和生产机器添加gem,因为Heroku应用程序是您系统的生产机器,而您的localhost是开发.
您的Gemfile应如下所示:
source 'https://rubygems.org' ruby '2.0.0' gem 'rails','4.0.0' gem 'bootstrap-sass','2.3.2.0' gem 'bcrypt-ruby','3.0.0' gem 'faker','1.1.2' gem 'will_paginate','3.0.4' gem 'bootstrap-will_paginate','0.0.9' group :development,:test do gem 'sqlite3','1.3.8' gem 'rspec-rails','2.13.1' end group :doc do gem 'sdoc','0.3.20',require: false end group :production do gem 'pg','0.15.1' gem 'rails_12factor' end