我有必要这样做,因为这对我来说似乎是合乎逻辑的:
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(车辆)和notification_booker(车辆?
谢谢!
好的。所以,愚蠢的我,我忘了提到我正在处理延迟的工作宝石。所以,问题是,我忘记在每个"mail"函数之后指定".delivery!"操作。
所以,它应该是这样的:
mail(:to => @vehicle.owner.email_address, :template_name => "n_o").deliver!
mail(:to => @vehicle.booker.email_address, :template_name => "n_b").deliver!
但仍然如此。感谢您的支持!
尝试:
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