使用ActionMailer选择特定的电子邮件模板

时间:2014-08-08 05:35:05

标签: ruby-on-rails ruby actionmailer

我在选择特定的电子邮件模板时遇到问题。我有以下邮件:

class NewsletterMailer < ActionMailer::Base
  def confirmation_email(subscriber)
    @subscriber = subscriber

    mail(to: @subscriber.email,
         subject: t('.confirmation_subject'))
  end
end

两个电子邮件模板存储在app / views / newsletter_mailer中:

  • confirmation_email.html.erb
  • confirmation_email.en.html.erb

有没有办法在此邮件程序操作中设置使用此功能:“confirmation_email.en.html.erb”?

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

试试这个:

mail(to: @subscriber.email,
         template_name: 'confirmation_email.en.html.erb',
         subject: t('.confirmation_subject'))

您可以在Mailer Views

了解更多信息