aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators
diff options
context:
space:
mode:
authorYuji Yaginuma <yuuji.yaginuma@gmail.com>2019-01-31 07:19:22 +0900
committerGitHub <noreply@github.com>2019-01-31 07:19:22 +0900
commit6729cef7516207efa1980de65fb4e1c72b4376d1 (patch)
treec7d073ffb0f7cabbb1aca6c10812af7c7f77bfb4 /railties/lib/rails/generators
parent535a8b995700a5875a898691b19b88969c22d264 (diff)
parent82e986670389aef7a61c860bacd347c60ff0b25c (diff)
downloadrails-6729cef7516207efa1980de65fb4e1c72b4376d1.tar.gz
rails-6729cef7516207efa1980de65fb4e1c72b4376d1.tar.bz2
rails-6729cef7516207efa1980de65fb4e1c72b4376d1.zip
Merge pull request #34980 from y-yagi/fixes_34979
Don't add `RAILS_ENV` in generate action
Diffstat (limited to 'railties/lib/rails/generators')
-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.