From 8be50181d3fbe0f727a68de33ec856efdf772487 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Mon, 17 Jul 2017 09:11:21 +0900 Subject: Set `RAILS_ENV` before load application file Since #29725, load application file when `dbconsole` command is executed. However, if do not set `RAILS_ENV` before reading the application file, can not connect to the env specified in option, so added the setting of `RAILS_ENV`. --- railties/lib/rails/commands/dbconsole/dbconsole_command.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails/commands') diff --git a/railties/lib/rails/commands/dbconsole/dbconsole_command.rb b/railties/lib/rails/commands/dbconsole/dbconsole_command.rb index a66eb16421..71b3455473 100644 --- a/railties/lib/rails/commands/dbconsole/dbconsole_command.rb +++ b/railties/lib/rails/commands/dbconsole/dbconsole_command.rb @@ -11,7 +11,7 @@ module Rails end def start - ENV["RAILS_ENV"] = @options[:environment] || environment + ENV["RAILS_ENV"] ||= @options[:environment] || environment case config["adapter"] when /^(jdbc)?mysql/ @@ -157,6 +157,9 @@ module Rails def perform extract_environment_option_from_argument + # RAILS_ENV needs to be set before config/application is required. + ENV["RAILS_ENV"] = options[:environment] + require_application_and_environment! Rails::DBConsole.start(options) end -- cgit v1.2.3