Reputation: 547
I would like to create a new function in my survey app that lets users set daily, weekly etc. notifications about the stats of their surveys. Also I would like to let users delete these notifications if they don't need them anymore, or their survey ends.
It seems fairly simple to create a Notification model, which stores the necessary information about the notification, but how do I schedule it to send out the e-mail with the stats daily, weekly ( whatever the user sets ) etc.
Sure I can use delayed_job or resque and reschedule everytime but that doesn't seem like an elegant solution.
Any ideas how to make this happen in the most elegant, and efficient way?
Upvotes: 1
Views: 360
Reputation: 71
I think you will find whenever gem useful
here's an example syntax for it:
every 3.hours do
runner "MyModel.some_process"
rake "my:rake:task"
command "/usr/bin/my_great_command"
end
every 1.day, :at => '4:30 am' do
runner "MyModel.task_to_run_at_four_thirty_in_the_morning"
end
Upvotes: 2