ActionMailer中的消息与邮件

时间:2014-01-06 22:10:35

标签: ruby-on-rails callback actionmailer

我遇到了一个问题,我试图将一个after_filter应用到Rails 3项目中的邮件程序。我包括以下代码:

include AbstractController::Callbacks

after_filter :check_notifications

def welcome(user)
  @user = user

  mail(to: email_with_name(@user.full_name, @user.email),
       subject: 'Get started with your new account!')
end

def check_notifications
  mail.to = mail.to.select { |user_email| User.find_by_email(user_email).receive_notification_emails == true } 
end

但是这会将电子邮件的主题更改为方法名称。因此,对于欢迎邮件,主题将是“欢迎”(有趣的是,它也是大写的)。如果我将mail.to更改为message.to,则修复此问题。我想知道为什么一个有效,另一个则无法触及after_filter中的消息。

谢谢!

0 个答案:

没有答案