将参数传递给自定义设计邮件程序

时间:2015-03-11 13:20:47

标签: ruby-on-rails ruby-on-rails-4 devise

我想在发送设计电子邮件时指定自定义'来自'电子邮件。

到目前为止,我已经创建了一个客户邮件程序,并且正在覆盖部分默认方法,但我不知道如何传递参数,例如current_user

示例:

class CustomDeviseMailer < Devise::Mailer
  helper :application
  include Devise::Controllers::UrlHelpers
  default template_path: 'devise/mailer'

  def confirmation_instructions(record, token, opts = {})
    Rails.logger.debug 'Sending custom confirmation instructions...'
    customer_responsible = current_user.company
    info_email           = customer_responsible.info_email
    opts[:from]          = info_email if info_email
    super
  rescue => e
    Rails.logger.debug e.inspect
    throw e
  end

end

0 个答案:

没有答案