I have this scenario: A user buys a product and when two days have passed after the transaction has been processed, I need to send a mail notification to buyer.
At this moment my idea is to use whenever gem and check build a cron job to check in each day and if 2 days have passed and if true, cron job will send mail notification.
I don't know if is ok to do this... Can you give me better solution?
You can use ActiveJob with perform_later
, like:
NotificationSendJob.set(wait: 2.days).perform_later(record)
Note that not all backends support this. You can see check feature matrix here: http://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html