合并rake db三兄弟命令

Published on:

打开lib/tasks,新建一个文档 dev.rake
touch lib/tasks/dev.rake
或者直接点击lib/tasks右键新建,输入文档名lib/tasks

编辑:

namespace :dev do
  desc "Rebuild system"
  task :build => ["tmp:clear", "log:clear", "db:drop", "db:create", "db:migrate"]
  task :rebuild => [ "dev:build", "db:seed" ]
end

这个文件自定义了两个命令:dev:builddev:rebuild
dev:build清理了tmp和log内容,同时合并了三兄弟"db:drop”、“db:create”,和”db:migrate”。

dev:rebuild合并了dev:builddb:seed命令。

Comments

comments powered by Disqus