rails, activerecord, get current connection specification

The answer is SomeModel.connection_config


Similar to the way that you can call connection on a model, you can make a call to connection on ActiveRecord::Base.

ActiveRecord::Base.connection_config

Look at the docs for ActiveRecord::Base, as there are other methods that allow you to get/set attributes about the connection.

Update

The connection_config became deprecated and will be removed from Rails 6.2. connection_db_config should be used instead:

ActiveRecord::Base.connection_db_config