Postgresql gem error not loaded Error deploying Ruby on Rails application on Heroku

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) 

Please help me solve this problem.

+6
ruby-on-rails
source share
3 answers

In Gemfile

 group :production do gem 'pg' end 

Then run bundle install and try deploying to Heroku.

If you want to use PostgreSQL in all environments, not just production (recommended), add a gem outside the :production group and remove other database adapters such as sqlite .

As an additional note, you can also add rails_12factor gem, as suggested by Heroku.

+8
source share

It worked for me

'pg', '~> 0.20'

Thanks Piers C

Got this answer from

Heroku and Rails: error loading Gem using Postgres, however it is reported in GEMFILE

+10
source share

Add pg to gemfile

  gem 'pg', '~> 0.20' 

then link the update and pass the Gemfile and Gemfile.lock to heroku.
simple include how gem 'pg' will not work.

+5
source share

All Articles