I am giving users an option to receive, say, emails at a periodicity of their choice, for example:
Every day at 5am
or
Every Friday at 11pm
or even
Every second Monday of the month at 12am
What would be my best choice for storing this kind of data in order to feed it to Whenever
gem?
Update
I was able to solve the question with @mudasobwa 's advice in combination with the cron_parser
gem. The process flow is:
- Get user's input from a select box on the frontend
- Parse it on the backend and de-code into cron format (e.g.
7
would mean that I will need to send emails every week, so the code could be "1 1 * * 1
"), store the value asperiodicity
. - Use the
cron_parser
gem to generate thenext_run
dateformat which is used to tell whenever gem which jobs it needs to perform that are dated.