Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails — Action Mailer conventions

Thinking about implementing of (a little bit) smarter notification system in my project. What I'd like to do is emailing user about few new let's say private messages once within certain range of time rather than each time he gets new message. Of course there will not be without delayed_job, but here I've got a couple of etic questions about ActionMailer:

  1. How many logic you can put in Mailer class?
  2. Can I perform database queries within Mailer class methods?
like image 324
jibiel Avatar asked Jan 20 '26 23:01

jibiel


1 Answers

So you'll be sending an email "Digest" of the various "Notifications" that occur in the system.

I suggest you move the logic that right now sends an email using ActionMailer to a Notification class. This will persist the notification with a flag set to false for notified (or similar).

Then, have a job run daily (or similar) that sends a digest email to people who have notifications they need to receive.

like image 137
Jesse Wolgamott Avatar answered Jan 22 '26 13:01

Jesse Wolgamott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!