May be there is another better method to do this. If you have the better way to do it, please tell me.
BTW, below code were successful running in rails3 and ruby 1.8.7
1. first, you should add open4 gem to your Rails project Gemfile
gem 'open4'
and run “bundle install” in terminal to install it in project dir.
2. add below code to config/deploy.rb, please change the namespace name to your own
namespace :your_namespance_name do
require 'open4'
rails_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
stdin, stdout, stderr = Open4::popen4("cd #{rails_root} && rake -T")
#please replace :your_namespance_name to your own, this code to grap you special of namespance rake tasks
stderr.read.scan(/your_namespance_name\:(\w+)/).each do |match|
desc "rake task named '#{match.last}'"
task match.last.to_sym, :roles => :app do
run "cd #{current_path}; RAILS_ENV=production rake railscasts:#{match}"
end
end
end
after do that, when you run cap -T in you command shell, you will be found the tasks from rake, also, it can invoked from the remote server of you own.
found your site on del.icio.us today and really liked it.. i bookmarked it and will be back to check it out some more later