Error loading the 'sqlite3' Active Record adapter. when I deploy in Heroku

后端 未结 5 1170
小鲜肉
小鲜肉 2021-01-26 03:55

I have a problem when I am deploying in Heroku:

/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/rubygems_integration.rb:408:in `block (2 levels) in         


        
5条回答
  •  情书的邮戳
    2021-01-26 04:54

    You should remove SQLite from your application and use Postgres in development, testing and production. There are many small incompatibilities between RDBMS's and you don't want to discover them when you push your app to production.

    1. Install Postgres on the local system.

    How to do this depends on your system. OS-X and Windows have simple installers. On Linux you would install it through your package manager.

    2. Remove the sqlite gem.

    # remove
    gem 'sqlite3', '~> 1.3.6'
    
    # add
    gem 'pg', '~> 0.18.4' # check rubygems.org for the latest version
    

    Run bundle update to regenerate the Bundle.lock.

    3. Configure database.yml

    default: &default
      adapter: postgresql
      pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
      timeout: 5000
    
    development:
      <<: *default
      database: 'my_app_development'
    
    # Warning: The database defined as "test" will be erased and
    # re-generated from your development database when you run "rake".
    # Do not set this db to the same as development or production.
    test:
      <<: *default
      database: 'my_app_test'
    
    # On Heroku you don't need the production section as it provides everything through 
    # ENV["DATABASE_URL"]
    # Heroku sets pretty good defaults as well so YAGNI.
    

    4. Commit and push

提交回复
热议问题