Rails从一个邮件程序功能发送2个不同的电子邮件

Dmi*_*tri 6 email ruby-on-rails actionmailer ruby-on-rails-3

我有必要这样做,因为这对我来说似乎合乎逻辑:

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")
Run Code Online (Sandbox Code Playgroud)

结束

问题是:我只收到最后一封电子邮件.因此,在上面的示例中,只有预订者才会收到电子邮件,并且没有任何内容发送给所有者.

问题是什么 ?怎么解决?我应该创建两个单独的邮件功能,例如notification_owner(vehicle)和notification_booker(vehicle),还是有一个更简单的解决方案?

谢谢!

shw*_*eta 0

尝试:

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 
Run Code Online (Sandbox Code Playgroud)