I'm developing an app in Rails 4 and not sure about how to implement a certain feature: basically I need to implement some sort of cron job. For instance, let's say I create an invoice in my app. I need the app to check the invoice due date and send a reminder to the customer that the invoice hasn't been paid. I want to achieve this without any input from the user.
How can I achieve this?
I've been thinking about this and thought about use a tool like whenever which would check the db every so often.
But is there another way to do it? Something more efficient?
Thanks
EDIT: Inefficiencies I'm trying to avoid:
The way I envisaged this could work is:
My concern is if there are thousands of invoices, it might be quite resource intensive to check all the entries and check whether they're within a specific time range. So, is there a better solution?
As an alternative to cron you could use this gem for the delayed job:
https://github.com/amitree/delayed_job_recurring
Sidekiq has also periodic jobs(although it is only present in sidekiq pro):