The Whiz of Oz
The Whiz of Oz

Reputation: 7043

Storing periodicity in Rails

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:

Upvotes: 1

Views: 114

Answers (1)

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 121000

whenever gem accepts a raw cron syntax. That is why the simplest way, involving as few transformations as possible, would be to store values in raw cron format.

That said, you probably should have a parser from/to allowed user input to/from raw cron format and that’s it.

Upvotes: 2

Related Questions