gpt4 book ai didi

ruby-on-rails - 设计电子邮件的 arg 数量错误

转载 作者:行者123 更新时间:2023-12-05 08:28:24 24 4
gpt4 key购买 nike

我以前没有遇到过这种情况,但是自从将我的 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'

邮件程序.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

最佳答案

似乎latest version需要一个额外的参数。
至少它适用于我的代码。这是我的自定义邮件程序类的工作代码。
请注意每个方法的额外参数 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

关于ruby-on-rails - 设计电子邮件的 arg 数量错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15040844/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com