设计电子邮件的错误数量

我之前没有经历过这个,但是自从我的rails网站移到Heroku后,每当我试图触发Devise发送电子邮件时,我都收到以下消息

Started POST "/members/forgot-password" for 127.0.0.1 at 2013-02-24 00:02:27 +1100 Processing by Devise::PasswordsController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"9G1P34ddbq2TN7SkmFuCet5d7fPMvWdSSpIaGqSZW9g=", "user"=>{"email"=>"paul.mcguane@*****"}, "commit"=>"Recover password"} User Load (3.1ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'paul.mcguane@me.com' LIMIT 1 Completed 500 Internal Server Error in 31ms ArgumentError - wrong number of arguments (2 for 1): app/mailers/devise/mailer.rb:8:in `reset_password_instructions' 

mailer.rb

  class Devise::Mailer < ::ActionMailer::Base include Devise::Mailers::Helpers def confirmation_instructions(record) devise_mail(record, :confirmation_instructions) end def reset_password_instructions(record) devise_mail(record, :reset_password_instructions) end def unlock_instructions(record) devise_mail(record, :unlock_instructions) end end 

似乎最新版本需要额外的论据。
至少它对我的代码有用。 这是我的自定义邮件程序类的工作代码。
请注意每个方法的额外参数action

  class MyMailer < ActionMailer::Base include Devise::Mailers::Helpers def confirmation_instructions(record, token, opts={}) @token = token devise_mail(record, :confirmation_instructions, opts) end def reset_password_instructions(record, token, opts={}) @token = token devise_mail(record, :reset_password_instructions, opts) end def unlock_instructions(record, token, opts={}) @token = token devise_mail(record, :unlock_instructions, opts) end # optional: this override method is from Devise::Mailers::Helpers def headers_for(action,opts={}) … end end 

尝试这种方式,因为’设计在最近的版本中引入了额外的选项参数’,如上面的答案所述

  def reset_password_instructions(record, opts={}) devise_mail(record, :reset_password_instructions) end 

这是因为Devise在最近的版本中引入了额外的选项参数。 我想你想要的东西:

 class Devise::Mailer < ::ActionMailer::Base include Devise::Mailers::Helpers def confirmation_instructions(record, opts={}) devise_mail(record, :confirmation_instructions, opts={}) end def reset_password_instructions(record) devise_mail(record, :reset_password_instructions, opts={}) end def unlock_instructions(record) devise_mail(record, :unlock_instructions, opts={}) end def headers_for(actions, opts={} # see http://stackoverflow.com/a/14698599/18706 end end 

最终卸载了gem,重新安装似乎解决了它:S