I already have a deploy.rb that can deploy my app on my production server.
My app contains a custom rake task (a .rake file in the lib/tasks directory).
I\
Here's what I put in my deploy.rb to simplify running rake tasks. It's a simple wrapper around capistrano's run() method.
def rake(cmd, options={}, &block)
command = "cd #{current_release} && /usr/bin/env bundle exec rake #{cmd} RAILS_ENV=#{rails_env}"
run(command, options, &block)
end
Then I just run any rake task like so:
rake 'app:compile:jammit'