From 48b249927375465a7102acc71c2dfb8d49af8309 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Fri, 9 Jun 2017 00:15:41 +0200 Subject: Deprecate environment as an argument for dbconsole and console People should rather rely on the `-e` or `--environment` options to specify in which environment they want to work. This will allow us to specify the connection to pick as a regular argument in the future. --- railties/lib/rails/command/environment_argument.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'railties/lib/rails/command/environment_argument.rb') diff --git a/railties/lib/rails/command/environment_argument.rb b/railties/lib/rails/command/environment_argument.rb index 05eac34155..3469463db5 100644 --- a/railties/lib/rails/command/environment_argument.rb +++ b/railties/lib/rails/command/environment_argument.rb @@ -13,6 +13,12 @@ module Rails def extract_environment_option_from_argument if environment self.options = options.merge(environment: acceptable_environment(environment)) + + ActiveSupport::Deprecation.warn "Passing the environment's name as a " \ + "regular argument is deprecated and " \ + "will be removed in the next Rails " \ + "version. Please, use the -e option " \ + "instead." elsif !options[:environment] self.options = options.merge(environment: Rails::Command.environment) end -- cgit v1.2.3 From 3777701f1380f3814bd5313b225586dec64d4104 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Sun, 16 Jul 2017 14:54:04 +0200 Subject: 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. --- railties/lib/rails/command/environment_argument.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails/command/environment_argument.rb') 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 -- cgit v1.2.3