我想知道如何在ActionMailer动作本身中有条件地放弃发送邮件。

class SomeMailer < ActionMailer::Base ... def some_emails some_models = Model.where(:a => 1) if !some_models.blank? mail(...) else # What to add here? # render :nothing => true doesn't work end endend


现在通过SomeMailer.some_emails.deliver!调用它返回一个
ArgumentError: A sender (Return-Path, Sender or From) required to send a message

最佳答案

而是将您的条件放在拨打SomeMailer.some_emails.deliver的地方!

关于ruby-on-rails - Rails 3-在ActionMailer Action 中放弃发送邮件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4452149/

10-14 01:41