To get the database configuration of all environments, run in a Rails console:

Rails.configuration.database_configuration

To get the database name ActiveRecord is going to use:

ActiveRecord::Base.connection.current_database

You can also use a specific model (useful if you have different models connecting to different databases):

Cat.connection.current_database