I have a calendar that can be either created, edited or destroyed. And every time any of these actions happen I call a method send_email to send the notification to all the registered users.
Should I instead place an observer for the calender class that listens for any changes and which then calls send_email by asking the another class to send the email?
Hi @ankur_kothari, I you can take advantage of ActiveRecord Callbacks like
after_destroy on the calendar model.
class Calendar < ActiveRecord::Base
I propose calling the
mailer, because calendar doesn’t need to know about mailing stuff (Single Responsability Principle)
Thanks @Jose_Alvarez. Will try this.