Jex’s Note

Rake

介紹

Rake 是像 C 語言的 Make 工具, 但是用 Ruby 寫的, 主要是用來執行預先寫好的腳本語言

依不同環境跑 tasks

lib/tasks/tasks.rake :

namespace :tasks do
  namespace :create do
    desc "Create all survey templates"
    task :all => [:task1, :task2]

    desc "desc1"
    task :task1 => :environment do
        Rails.logger.info(1)
    end

    desc "desc2"
    task :task2 => :environment do

    end
  end
end

lib/tasks/dev.rake :

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
  • rake dev:build : 重建一個乾淨的環境
  • rake dev:rebuild : 跑完 dev:build 再跑 db:seed

ref: 參考這裡

Comments