Search code examples
upgraderuby-on-rails-5multiple-databases

Rails 5 Upgrade Issue: database configuration does not specify adapter


I received the following error after upgrading my application to Rails 5 and it is somewhat cryptic:

...connection_specification.rb:170:in `spec': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)

Solution

  • 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.