diff options
author | Robin Dupret <robin.dupret@gmail.com> | 2017-07-16 14:54:04 +0200 |
---|---|---|
committer | Robin Dupret <robin.dupret@gmail.com> | 2017-07-16 15:10:39 +0200 |
commit | 3777701f1380f3814bd5313b225586dec64d4104 (patch) | |
tree | e77262bb855ee85c59b618648f17e2473854c815 /railties/lib/rails/command/environment_argument.rb | |
parent | 48b249927375465a7102acc71c2dfb8d49af8309 (diff) | |
download | rails-3777701f1380f3814bd5313b225586dec64d4104.tar.gz rails-3777701f1380f3814bd5313b225586dec64d4104.tar.bz2 rails-3777701f1380f3814bd5313b225586dec64d4104.zip |
Properly expand the environment's name
Running the `console` and `dbconsole` commands with a regular argument
as the environment's name automatically expand it to match an existing
environment (e.g. dev for development).
This feature wasn't available using the `--environment` (a.k.a `-e`)
option.
Diffstat (limited to 'railties/lib/rails/command/environment_argument.rb')
-rw-r--r-- | railties/lib/rails/command/environment_argument.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/railties/lib/rails/command/environment_argument.rb b/railties/lib/rails/command/environment_argument.rb index 3469463db5..9582509840 100644 --- a/railties/lib/rails/command/environment_argument.rb +++ b/railties/lib/rails/command/environment_argument.rb @@ -7,6 +7,9 @@ module Rails included do argument :environment, optional: true, banner: "environment" + + class_option :environment, aliases: "-e", type: :string, + desc: "Specifies the environment to run this console under (test/development/production)." end private @@ -19,7 +22,9 @@ module Rails "will be removed in the next Rails " \ "version. Please, use the -e option " \ "instead." - elsif !options[:environment] + elsif options[:environment] + self.options = options.merge(environment: acceptable_environment(options[:environment])) + else self.options = options.merge(environment: Rails::Command.environment) end end |