我有必要这样做,因为这对我来说似乎合乎逻辑:
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")
端
问题是:我只收到最后电子邮件。因此,在上面的示例中,只有预订者才会收到电子邮件,并且没有任何内容发送给所有者。
有什么问题?怎么解决?我应该创建两个单独的邮件功能,例如notification_owner(vehicle)和notification_booker(vehicle),还是有一个更简单的解决方案?
谢谢!
答案 0 :(得分:1)
确定。所以,愚蠢的我,我忘了提到我正在处理delayed_jobs gem。所以,问题是,我忘了指定“.deliver!”每个“邮件”功能后的动作。
所以,它应该是这样的:
mail(:to => @vehicle.owner.email_address, :template_name => "n_o").deliver!
mail(:to => @vehicle.booker.email_address, :template_name => "n_b").deliver!
但是仍然。感谢您的支持!
答案 1 :(得分: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