aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2019-01-19 16:39:18 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2019-01-19 16:39:18 +0900
commit82e986670389aef7a61c860bacd347c60ff0b25c (patch)
tree3a56728be6945def8210e0024bc4317f635c7a9b /railties/lib
parent3c6cfdf7adf4848976b7f425b1811d447b130f6a (diff)
downloadrails-82e986670389aef7a61c860bacd347c60ff0b25c.tar.gz
rails-82e986670389aef7a61c860bacd347c60ff0b25c.tar.bz2
rails-82e986670389aef7a61c860bacd347c60ff0b25c.zip
Don't add `RAILS_ENV` in generate action
In the case of generator, `RAILS_ENV` is interpreted as an argument as it is. Avoid this because it will result unintended by the user. Fixes #34979.
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails/generators/actions.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb
index 3856a74a39..1a5f2ff203 100644
--- a/railties/lib/rails/generators/actions.rb
+++ b/railties/lib/rails/generators/actions.rb
@@ -222,6 +222,7 @@ module Rails
log :generate, what
options = args.extract_options!
+ options[:without_rails_env] = true
argument = args.flat_map(&:to_s).join(" ")
execute_command :rails, "generate #{what} #{argument}", options
@@ -284,14 +285,15 @@ module Rails
# based on the executor parameter provided.
def execute_command(executor, command, options = {}) # :doc:
log executor, command
- env = options[:env] || ENV["RAILS_ENV"] || "development"
+ env = options[:env] || ENV["RAILS_ENV"] || "development"
+ rails_env = " RAILS_ENV=#{env}" unless options[:without_rails_env]
sudo = options[:sudo] && !Gem.win_platform? ? "sudo " : ""
config = { verbose: false }
config[:capture] = options[:capture] if options[:capture]
config[:abort_on_failure] = options[:abort_on_failure] if options[:abort_on_failure]
- in_root { run("#{sudo}#{extify(executor)} #{command} RAILS_ENV=#{env}", config) }
+ in_root { run("#{sudo}#{extify(executor)} #{command}#{rails_env}", config) }
end
# Add an extension to the given name based on the platform.