"postgresql gem is not loaded" error deploying a Ruby on Rails application on Heroku

ruby-on-rails

Solution

In your `Gemfile`

group :production do
  gem 'pg'
end

Then run `bundle install` and try to deploy on Heroku.

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

As a side note, you may also want to add the `rails_12factor` gem as suggested by Heroku.

Problem

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 to solve this issue.

Original source

Related problems