如何为rails邮件程序中的所有电子邮件的标题部分设置默认值

时间:2013-10-15 13:19:45

标签: ruby-on-rails actionmailer

我有一个邮件定义如下:

class AdminMailer < ActionMailer::Base
  default from: "site@myapp.com", to: Rails.application.config.admin_email
  def notify
     mail subject "We have a new uer
  end 
end

我需要添加一个Precedence =“bulk”的默认标头。 如果我将headers["Precedence"] = "bulk"添加到 notify()方法中,则可行。但我希望这是所有方法的默认值。 我试过了

default from: "site@itcentralstation.com", headers: {"Precedence" => "bulk"}

default from: "site@itcentralstation.com", "headers" => {"Precedence" => "bulk"}

两次我都收到了错误: NoMethodError - 未定义的方法`encoding'for {“Precedence”=&gt;“bulk”}:哈希:

1 个答案:

答案 0 :(得分:2)

你试过吗

default from: "site@itcentralstation.com", "Precedence" => "bulk"