?
ruby on rails 生成task的方法:
$ rails g task task_namespace task_name1 task_name2
$ create lib/tasks/task_namespace.rake
?
task文件里面:
?
namespace :task_namespace do
?
? desc "this is describe"
? task :task_name1 => :environment do
?
? end
?
? desc "this is also describe"
? task :task_name2 => :environment do
?
? end
?
end
?
使用 rake -T 查看所有task
?
rake?task_namespace:task_name1 ? ?# this is describe
rake?task_namespace:task_name2 ? ?# this is also describe
?