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

后端 未结 4 1722
情书的邮戳
情书的邮戳 2020-12-17 15:50

I am trying to use postgresql with Ruby on Rails on Heroku but got an error

Specified \'postgresql\' for          


        
相关标签:
4条回答
  • 2020-12-17 16:00

    Add pg in gemfile

     gem 'pg', '~> 0.20'
    

    then bundle update & commit Gemfile & Gemfile.lock to heroku.
    simple include like gem 'pg' will not work.

    0 讨论(0)
  • 2020-12-17 16:01

    I added the following version into my gemfile, and it is solved.

    gem "pg", "~> 0.18"

    0 讨论(0)
  • 2020-12-17 16:09

    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.

    0 讨论(0)
  • 2020-12-17 16:20

    This worked for me

    gem 'pg', '~> 0.20'

    Thanks to Piers C

    Got this answer from

    Heroku and Rails: Gem Load Error with Postgres, however it is Specified in GEMFILE

    0 讨论(0)
提交回复
热议问题