5

I upgraded an app to Rails 6.1.0 (from 6.0.3.3, by creating a new api-only app, adding RSpec, then copying needed files over manually).

I am seeing the following warning when I run RSpec:

DEPRECATION WARNING: connection_config is deprecated and will be removed from Rails 6.2 (Use 
connection_db_config instead) (called from <top (required)> at 
[...app/models/application_record.rb:1].

I did not change the ApplicationRecord class from the default:

class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true
end

I only see this warning when I run RSpec. I have not seen it in the rails console or in the Rails server log.

Here is my config/database.yml:

default: &default
  adapter: postgresql
  encoding: unicode
  host: <%= ENV.fetch('DATABASE_HOST', 'localhost') %>
  username: <%= ENV.fetch('POSTGRES_USER', 'postgres') %>
  password: <%= ENV.fetch('POSTGRES_PASSWORD', '') %>
  database: <%= ENV.fetch('POSTGRES_DB', 'myapp_development') %>
  pool: 5
  timeout: 5000

development:
  <<: *default

test:
  <<: *default
database: myapp_test

production:
  <<: *default

Any suggestions on how to get rid of this?

Mark Fraser
  • 3,160
  • 2
  • 29
  • 48
  • 1
    I got same situation but warning path was pointing to `devise_auth_token`. That gem is using deprecated `connection_config` instead of `connection_db_config`. When I replaced manually deprecated line in gem file - warning went away. I searched in rspec for place where `connection_config` is used but I found nothing. Are you using any other gems ? – jakubm Dec 31 '20 at 11:31
  • Thanks for the suggestion @jakubm. See my answer. – Mark Fraser Jan 01 '21 at 20:00
  • Yeah, I am also using `money-rails` but nothing was pointing to it. – jakubm Jan 01 '21 at 20:58

2 Answers2

5

After further debugging I was able to trace it to the money-rails gem.

https://github.com/RubyMoney/money-rails/issues/601

Mark Fraser
  • 3,160
  • 2
  • 29
  • 48
  • 1
    I was seeing this in both money-rails AND honeybadger (v4.5), upgrading both has fixed it. Morale of the story is to have a look at your rspec logs, they should highlight which line/gem is causing the issues. Thanks Mark! – Alan Mar 31 '21 at 08:55
  • adding `ActiveRecord.legacy_connection_handling = false` in `application.rb` removed the warning. – Quentin Gaultier Jul 24 '22 at 00:52
1

The root fix for me:

From ActiveRecord::Base.connection_config.to_h.deep_dup

To ActiveRecord::Base.connection_db_config.configuration_hash.deep_dup

DBulgatz
  • 39
  • 6