I have my transactional email system, and by default, people receive emails as events occur:
class Comment after_create :email_original_poster def email_original_poster UserMailer.delay.notify_author_of_comment self end end
However, instead of receiving mail as if somehow, a piece of my users would prefer a daily or weekly digest.
What is the cleanest most elegant way to implement this?
I have already started delayed_job
, but this does not look like a delayed_job
task, since I queue up with data that needs to be acted upon, and not with actions that need to be performed.
... without rethinking the queuing system
I know that the queued_emails
table is the obvious solution, and of course I could do that. The reason I ask the question is because for this you need to re-create the queue system. Not only are there many queuing systems, but as this well-worded post from Percona points out, it’s recommended that you don’t turn it off yourself:
http://www.engineyard.com/blog/2011/5-subtle-ways-youre-using-mysql-as-a-queue-and-why-itll-bite-you/
You implemented a digest, you used delayed_job
and what did you learn?
source share