【问题标题】:Reset password on sorcery isn't working重置魔法密码不起作用
【发布时间】:2015-12-01 14:18:05
【问题描述】:

我正在尝试为用户注册实施魔法 gem,但不明白为什么我收到与重置密码相关的错误。

我正在关注本指南https://github.com/NoamB/sorcery/wiki/Reset-password

错误:

To use reset_password submodule, you must define a mailer (config.reset_password_mailer = YourMailerClass).

# config/initializers/sorcery.rb

  Rails.application.config.sorcery.configure do |config|
    config.user_config do |user|
      user.reset_password_mailer = UserMailer
    end
  end

user_mailer.rb

class UserMailer < ActionMailer::Base
  default from: "from@example.com"

  def reset_password_email(user)
    @user = User.find user.id
    @url  = edit_password_reset_url(@user.reset_password_token)
    mail(:to => user.email,
         :subject => "Your password has been reset")
  end
end

【问题讨论】:

    标签: ruby-on-rails ruby gem sorcery


    【解决方案1】:

    在初始化器sorcery.rb中取消注释行:

    user.reset_password_email_method_name = :reset_password_email
    

    添加检查文档: https://github.com/Sorcery/sorcery/wiki/Reset-password

    【讨论】:

      【解决方案2】:

      您是否已经重新启动了您的 Rails 服务器? 如果将任何内容更改为初始化程序,则需要重新启动 Rails 服务器。

      【讨论】:

      • 是的,在我更改了 sorcery.rb 之后,我重新启动了服务器。
      猜你喜欢
      • 2016-04-30
      • 2015-08-26
      • 2019-01-28
      • 2015-08-25
      • 2014-12-22
      • 1970-01-01
      • 1970-01-01
      • 2015-07-01
      • 2016-12-22
      相关资源
      最近更新 更多