Reputation: 69
I'm new to Rails cron job. Here's my question, I have an attribute called status
and expiration date
, let's say the expiration date
is 2017/10/21
, on that particular date, I want to update the status
from Effect to Due, how am I supposed to do that. So far here's what I know,
every 1.day, :at => '12:00 am' do
# do something here
end
It would be appretiated if somebody points me some direction.
Upvotes: 0
Views: 140
Reputation: 1736
I think you should filter the records then update them. Something like this:
every 1.day, :at => '12:00 am' do
Record.where(expiration_date: Date.today)
.update_all(status: 'due')
end
Upvotes: 1