Permalink
Browse files

Add :env and :sudo options to TemplateRunner#rake.

Examples :

  rake("gems:install", :sudo => true)
  rake("db:migrate", :env => "production")
  • Loading branch information...
1 parent ef0b1cb commit e52affb210f457ea5a1714af03e3106f6d9f4b1e @lifo lifo committed Dec 4, 2008
Showing with 6 additions and 3 deletions.
  1. +6 −3 railties/lib/rails_generator/generators/applications/app/template_runner.rb
View
9 railties/lib/rails_generator/generators/applications/app/template_runner.rb
@@ -258,11 +258,14 @@ def run(command)
# ==== Example
#
# rake("db:migrate")
- # rake("db:migrate", "production")
+ # rake("db:migrate", :env => "production")
+ # rake("gems:install", :sudo => true)
#
- def rake(command, env = 'development')
+ def rake(command, options = {})
puts "running rake task #{command}"
- in_root { `rake #{command} RAILS_ENV=#{env}` }
+ env = options[:env] || 'development'
+ sudo = options[:sudo] ? 'sudo ' : ''
+ in_root { `#{sudo}rake #{command} RAILS_ENV=#{env}` }
end
# Just run the capify command in root

0 comments on commit e52affb

Please sign in to comment.