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\
I personally use in production a helper method like this:
def run_rake(task, options={}, &block)
command = "cd #{latest_release} && /usr/bin/env bundle exec rake #{task}"
run(command, options, &block)
end
That allows to run rake task similar to using the run (command) method.
NOTE: It is similar to what Duke proposed, but I: