1

所以我试图覆盖“发件人”字段,因此它实际上包含邀请者的姓名,而不是系统默认值。

我已经按照这里的说明https://github.com/plataformatec/devise/wiki/How-To:-Use-custom-mailer

我已经设置了自定义邮件程序,但我遇到的问题是opts,与文档中的示例不同,它看起来不像是可以修改的对象。

有人有什么建议吗?

class MCDeviseMailer < Devise::Mailer
  helper :application # gives access to all helpers defined within `application_helper`.

  def invitation_instructions(record)        
    # opts[:from] = "#{resource.invited_by.full_name rescue "Mission Control"} <notifications@#{DOMAIN}>"
    super
  end
end

非常感谢!

4

2 回答 2

0

你必须猴子补丁send_devise_notification。把这样的东西放在User

def send_devise_notification(notification, *args)
  if :invitation_instructions == notification
    args << {
      from: "#{inviter_name} <#{inviter_email}>",
    }
  end
  super
end
于 2014-02-27T03:08:40.457 回答
0

看看设计维基

您可以编写自己的指令。简单地覆盖

def invitation_instructions(record, opts = {})
  ...
end
于 2015-07-11T19:55:54.120 回答