我需要系統每天運行以下代碼,但我不知道如何做到這一點。Rails Everyday Action
@user = User.all
date = Date.today
if date.workingday?
@user.each do |user|
if !Bank.where(:user_id => user.id , :created_at => (date.beginning_of_day..date.end_of_day) , :bank_type => 2).exists?
banco = Bank.new()
banco.user = user
banco.bank_type = 2
banco.hours = 8
banco.save
end
end
end
看看[發條](https://github.com/tomykaira/clockwork)寶石。 –