如果:在ActionMailer中bcc地址为空,如何停止发送到`:to`地址的`mail`动作?

时间:2017-04-03 10:36:16

标签: ruby-on-rails actionmailer

我有一个actinmailer方法,如果@receiver符合某些条件并且有@default_mail,则会填充to。它将邮件发送到BCC中的接收者和def mail_users @default_mail = "user@gmail.com" @latest_listing_mail= Equipment.joins(:user).last.user.email @wanted_req_mail = WantedEquipment.where(sub_category_id: "#{a}", status: 2).pluck(:email) @wanted_req_mail.include? @latest_listing_mail if true @receiver = @wanted_req_mail.delete(@latest_listing_mail) @receiver = @wanted_req_mail mail(bcc: @receiver, to: @default_mail) end end 字段中的default_mail。它如下:

mail

如果@receiver为空,我不希望scipy.sparse.save_npz执行。我如何实现这一目标?

1 个答案:

答案 0 :(得分:1)

只需添加条件

mail(bcc: @receiver, to: @default_mail) if @receiver.present?

你可能想删除这个条件

if true # doesn't make sense
end