rails6 DBの設定情報を確認する

rails6 DBの設定情報を確認する

rails6でrails cを使用して、現在のDBの設定情報を確認するまでの手順を記述してます。Railsのバージョンは6.1.1を使用してます。

環境

  • OS CentOS Linux release 7.9.2009 (Core)
  • Ruby 2.7.2
  • Rails 6.1.1
  • rbenv 1.1.2-40-g62d7798

設定情報確認

「rails c」でコンソールを立ち上げて、「ActiveRecord::Base.connection_config」を実行すると

rails c

irb(main):001:0> ActiveRecord::Base.connection_config
DEPRECATION WARNING: connection_config is deprecated and will be removed from Rails 6.2 (Use connection_db_config instead) (called from irb_binding at (irb):1)
=> {:adapter=>"postgresql", :pool=>5, :username=>"pgadmin", :password=>"password", :host=>"127.0.0.1", :timeout=>5000, :database=>"sample_development"}

現在のDBの設定情報を確認することができます。