aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/command/environment_argument.rb
diff options
context:
space:
mode:
authorYuji Yaginuma <yuuji.yaginuma@gmail.com>2019-03-15 08:24:19 +0900
committerGitHub <noreply@github.com>2019-03-15 08:24:19 +0900
commit1cdc6c6576afe9a9fa67a6b313080a7dc62188d9 (patch)
treea09d66331fc1739ee7a65b66c545c98720b06503 /railties/lib/rails/command/environment_argument.rb
parent85984e50311b7138504abe1be9bbe99f96dde8ef (diff)
parentc801b232bcb5d885e846e33e26becd33631b8c5b (diff)
downloadrails-1cdc6c6576afe9a9fa67a6b313080a7dc62188d9.tar.gz
rails-1cdc6c6576afe9a9fa67a6b313080a7dc62188d9.tar.bz2
rails-1cdc6c6576afe9a9fa67a6b313080a7dc62188d9.zip
Merge pull request #35599 from y-yagi/improve_environment_argument_handling
Properly expand the environment's name in all commands
Diffstat (limited to 'railties/lib/rails/command/environment_argument.rb')
-rw-r--r--railties/lib/rails/command/environment_argument.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/railties/lib/rails/command/environment_argument.rb b/railties/lib/rails/command/environment_argument.rb
index fdc5ee92d9..0cb3f1ce1e 100644
--- a/railties/lib/rails/command/environment_argument.rb
+++ b/railties/lib/rails/command/environment_argument.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require "active_support"
+require "active_support/core_ext/class/attribute"
module Rails
module Command
@@ -8,16 +9,16 @@ module Rails
extend ActiveSupport::Concern
included do
- class_option :environment, aliases: "-e", type: :string,
- desc: "Specifies the environment to run this console under (test/development/production)."
+ class_attribute :environment_desc, default: "Specifies the environment to run this #{self.command_name} under (test/development/production)."
+ class_option :environment, aliases: "-e", type: :string, desc: environment_desc
end
private
- def extract_environment_option_from_argument
+ def extract_environment_option_from_argument(default_environment: Rails::Command.environment)
if options[:environment]
self.options = options.merge(environment: acceptable_environment(options[:environment]))
else
- self.options = options.merge(environment: Rails::Command.environment)
+ self.options = options.merge(environment: default_environment)
end
end