Rails Send 2 different emails from a single mail program function

I need to do this because it seems logical to me:

def notification(vehicle) @vehicle = vehicle mail(:to => @vehicle.owner.email_address, :template_name => "n_o") mail(:to => @vehicle.booker.email_address, :template_name => "n_b") 

end

The problem is this: I only get the last message. Thus, in my example above, only the booklet will receive an email and nothing is sent to the owner.

What is the problem? How to solve it? Should I create two separate mailing functions, such as notification_owner (vehicle) and notification_booker (vehicle), or is there a simpler solution?

Thanks!

+4
source share
2 answers

Ok So, stupid me, I forgot to mention that I'm dealing with jewel with delay_jobs. So the problem is that I forgot to specify ".deliver!". action after each "mail".

So it should look like this:

 mail(:to => @vehicle.owner.email_address, :template_name => "n_o").deliver! mail(:to => @vehicle.booker.email_address, :template_name => "n_b").deliver! 

But still. Thank you for your support!

+1
source

Try:

 def notification(vehicle,template_name) @vehicle = vehicle mail(:to => @vehicle.owner.email_address, :template_name => template_name) end Mailer.notification(@vehicle,"n_o").deliver Mailer.notification(@vehicle,"n_b").deliver 
0
source

All Articles