简体   繁体   English

设计密码恢复:未定义的方法“ reset_password_token”

[英]Devise password recovery: undefined method “reset_password_token”

I have Devise 3.4.1. 我有设计3.4.1。 Everything works fine except password recovery. 一切正常,除了恢复密码。 I open a page with password recovery, enter my email, click "Submit"... And get this error: 我打开一个包含密码恢复的页面,输入我的电子邮件,单击“提交” ...,并收到此错误:

undefined method `reset_password_token=' for #<User:0x000000057c3af8>

I found the same question here - NoMethodError - undefined method `reset_password_token' for User:Class: - if I understood it correctly author suggest overriding one of Devise's methods, but I can't understand which method exactly needs to be overridden and most important - why. 我在这里找到了相同的问题-NoMethodError-未定义的方法“ reset_password_token”用于User:Class: -如果我正确理解它,那么作者建议重写Devise的方法之一,但我不明白到底是哪个方法应该被重写,并且最重要-为什么。 Why it just doesn't work out of the box. 为什么它开箱即用。

I'm using Mongoid so I added this to User model: 我正在使用Mongoid,因此将其添加到了User模型中:

  field :reset_password_token, type: String
  field :reset_password_sent_at, type: String

Now everything works fine. 现在一切正常。 I didn't know I have to add those fields. 我不知道我必须添加这些字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM