Rails 3 Overriding Devise Mailer

时间:2012-12-04 17:01:18

标签: ruby-on-rails-3 devise actionmailer mailchimp

我正在开发一个与Mandrill(MailChimp的交易电子邮件服务)紧密集成的应用程序,我正在尝试覆盖Devise Mailer,但出于某种原因,当我向API发送API调用时,我会收到他们的电子邮件,但是Devise还给我发了一封电子邮件(这是空白的)。

这是我的DeviseMailer

class MyDeviseMailer < Devise::Mailer
  def reset_password_instructions(record)
    mandrill = Mandrill::API.new("#{MandrillConfig.api_key}")
    mandrill.messages 'send-template',
            { 
              :template_name => 'Forgot Password', 
              :template_content => "",
              :message => {
                :subject => "Forgot Password",
                :from_email => "test@test123.com",
                :from_name => "Company Support",
                :to => [
                  {
                    :email => record.email
                  }
                ],
                :global_merge_vars => [
                  {
                    :name => "FIRST_NAME",
                    :content => record.first_name
                  },
                  {
                    :name => "FORGOT_PASSWORD_URL",
                    :content => "<a href='#{edit_user_password_url(:reset_password_token => record.reset_password_token)}'>Change My Password</a>"
                  }
                ]
              }
            }
      #We need to call super because Devise doesn't think we have sent any mail 
      super
  end
end

我在super找到{{1}}的电话:http://qnundrum.com/answer.php?q=254917

1 个答案:

答案 0 :(得分:12)

我遇到了类似的问题。

您是否更新了设计初始化程序文件(devise.rb)以指定以下内容:

config.mailer = "MyDeviseMailer"  

您还需要将views / devise / mailer中的所有文件移动到views / mydevisemailer。

我也会重启你的服务器。