Database Configuration Does Not Specify Adapter

Rails 6 on Heroku: ActiveRecord::AdapterNotSpecified: database configuration does not specify adapter

The problem has been solved by adding the 'adapter' to 'production' in the database.yml. This wasn't necessary when our project was on Rails 4 and 5.

production:
adapter: postgresql

ActiveRecord::AdapterNotSpecified database configuration does not specify adapter

For you app to work locally you need to:

  1. Install Postgresql on your machine
  2. Create a database for your development needs (let's call it my_app_development)
  3. Change your database.yml to:

    default: &default
    adapter: postgresql
    encoding: unicode
    # For details on connection pooling, see rails configuration guide
    # http://guides.rubyonrails.org/configuring.html#database-pooling
    pool: 5

    development:
    <<: *default
    database: my_app_development
  4. run rake db:migrate

Database configuration does not specify adapter (Sinatra + Heroku + Activerecord)

I had the same problem today, and contacted Heroku support for assistance.

They directed me to a recent change in their Ruby build pack, see here: https://devcenter.heroku.com/changelog-items/709

I updated my database.yml file to reflect the change, and reference the DATABASE_URL for production, and my app is deploying again.

production:
url: <%= ENV['DATABASE_URL'] %>

Rails 5 Upgrade Issue: database configuration does not specify adapter

I found the solution to this problem, it turns out that in my case since I was connecting to multiple databases that there was a subtle change in what Rails 5 expected over Rails 4.

If you are connecting to multiple databases the establish_connection used within the model connecting to the separate database requires a symbol instead of a string in Rails 5.

Works

establish_connection :secondary_database

Where as the following no longer works:

establish_connection "secondary_database"

In my case some of my old database connections had used the string argument and were failing, causing me to think that there was an strange incompatibility between Rails 5 and my code base. I thought I would share this as I do not see it documented anywhere specifically.



Related Topics



Leave a reply



Submit