vishal
vishal

Reputation: 279

Email Digest for Rail Application

I am working on a rails application where people can follow each other and post comments. Currently I use delayed_jobs for people to get notifications when someone follows them or post a comment. My question is how can I collect all the notifications for one user and create an email digest for notifications and send the email at the end of the day. Putting it in another way, can we collate the delayed_jobs?

Upvotes: 3

Views: 1003

Answers (2)

Michael Fairley
Michael Fairley

Reputation: 13208

Delayed_job won't do this for you, but it's straightforward enough to do yourself.

The simplest thing to do would be to write a rake task that you run once a day, and have the task find all the activity for that user that has occurred in the past day, and then send them an email about that activity.

Upvotes: 3

Jesse Wolgamott
Jesse Wolgamott

Reputation: 40277

Right now you are sending an email on a set of actions (following event or comment event).

Instead, if your user is digest-enabled, insert a record into a pending-email-digest table, and then daily process the email digests via a cron job.

Upvotes: 3

Related Questions