Reputation: 111050
I'd like to learn how to build a rake task for my rails 3 app that does two things.
Commands for the above steps:
rake cache:s3
heroku jammit:deploy --app #{app}
Here's what I have /lib/tasks/deployer.rake
task :deployit do
puts '=== Storing assets on s3 ==='
run "rake cache:s3"
puts '=== Deploying to Heroku ==='
run "heroku jammit:deploy --app #{app}"
end
def run(cmd)
shell cmd
if $?.exitstatus == 0
display "[OK]"
else
display "[FAIL]"
end
end
But that errors with 'undefined method `shell' for main:Object'
Suggestions on how to make this work? Should this be a task or something else?
Thanks
Upvotes: 0
Views: 470
Reputation: 514
The first task is another rake task, which will run if it is a dependency of the :deployit
task. Your current code would loads rake twice.
If you use system like Arun suggested you would get:
task :deployit => 'cache:s3' do
puts '=== Deploying to Heroku ==='
system "heroku jammit:deploy --app #{app}"
end
Upvotes: 2
Reputation: 6857
Use system command instead. For more info: http://blog.jayfields.com/2006/06/ruby-kernel-system-exec-and-x.html
Upvotes: 2