Cron solutions in rails are numerous and pretty good. That's not what I'm struggling with here.
Instead, what I'm having trouble with is letting users create their own recurring tasks (like reminders) - specifically how to model and store these in the DB (a good UI for it is non-trivial too - would be awesome if there was code out there for that). Google calendar is a great example here (the UI to add an event, not the entire calendar)...they should be able to do daily at 1pm CST, or mon/wed/fri, or weekly, etc. Whatever cron solution is being used would then need to poll the database to see which reminders needed to be sent at that hour, etc.
Anyone seen a good plugin/gem for this in rails? Seems like there would be something out there for it, but I haven't found it yet.
Thanks!
Currently thinking about using a plugin like this to store recurrences in a table http://github.com/fnando/recurrence/tree/master
each reminder would have one recurrence object, and the reminder would also keep a datetime field when it's supposed to send it's next one. Then the cron could...
get all reminder's whose "next_send" date has passed
for each reminder
send it
update the "next_send" field using the recurrence object
end
If there are better solutions or I'm going down the wrong path, input always appreciated.
I have always found ical (the RFC, not the program) solutions to be the best approach for working with recurring events. There are a few good Ruby libraries for dealing with ical, and the newest kid on the block is ri_cal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With