Let's say I want to build a Reminder App. It allow user to set a time which will remind them to do their work. For example: 24th March 07:03 PM.
The easiest way I can think of is to use whenever
gem and set a crontab every minutes and check if there is any reminder needs to be fire.
But I was wondering if there is a better way to achieve this. Or if now users want to set a reminder in seconds, what can I do? For example: 24th March 07:03:33 PM.
Another way to do this and be accurate to seconds is with a delayed background job.
For example resque_scheduler
When a user creates a reminder you enqueue a job at specific time.
reminder = Reminder.last
# assuming reminder has a column reminder_at and there is
# a job that processes these reminders, ProcessReminderJob
Resque.enqueue_at(reminder.remind_at, ProcessReminderJob, reminder.id)