diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-12-04 01:07:18 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-12-04 01:08:36 +0100 |
commit | e52affb210f457ea5a1714af03e3106f6d9f4b1e (patch) | |
tree | e5d8e3b483cdb5f61b27fd4027117ce0249b7a4e /railties/lib | |
parent | ef0b1cbb1b8e328fb3ac3b82ac5654bb95dbb2d6 (diff) | |
download | rails-e52affb210f457ea5a1714af03e3106f6d9f4b1e.tar.gz rails-e52affb210f457ea5a1714af03e3106f6d9f4b1e.tar.bz2 rails-e52affb210f457ea5a1714af03e3106f6d9f4b1e.zip |
Add :env and :sudo options to TemplateRunner#rake.
Examples :
rake("gems:install", :sudo => true)
rake("db:migrate", :env => "production")
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails_generator/generators/applications/app/template_runner.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/railties/lib/rails_generator/generators/applications/app/template_runner.rb b/railties/lib/rails_generator/generators/applications/app/template_runner.rb index d9261ebe8f..3a4815c0dd 100644 --- a/railties/lib/rails_generator/generators/applications/app/template_runner.rb +++ b/railties/lib/rails_generator/generators/applications/app/template_runner.rb @@ -258,11 +258,14 @@ module Rails # ==== 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 |