ruby on rails 3.2 - Is it possible to have a mail Observer that handle only a specific Mailer? -


is possible have mail observer handle specific mailer ?

so can possibly have different mailer - mail-observer pair work handle task after mail has been sent.

for instance 1 mail-obser delete temporary generated attached-files, while log sending of specific type of message (of specific mailer).

if possible, illustrate how make "connection" works between mailer , mail-observer classes ?

many thanks

i found example telling put file in config/initializers/ :

actionmailer::base.register_observer(mymailobserver) 

however global setting.

i found solution after digging api. realized register_observer() class method, tried apply on app/mailer/report_mailer.rb class :

class reportmailer < actionmailer::base   default from: "my_email@my_domaine.com"    def monthly_report(user, report_name, file_name, file_path)     @user = user     @report_name = report_name     attachments[file_name] = file.read(file_path)     mail(:to => user.email, :subject => "generated report #{report_name} (automatic message)")   end end 

i managed apply initialization of observer mailer in config/initializers/my_mailer_observer_initializer.rb :

reportmailer.register_observer(mymailobserver) 

so got mymailerobserver in relationship reportmailer class , no other mailer class.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -