ruby-on-rails – 如何使用设计恢复密码(Ruby on Rails)
发布时间:2020-12-17 02:38:07 所属栏目:百科 来源:网络整理
导读:我正在尝试使用设计恢复用户的密码,但它会生成以下错误 undefined method `reset_password_sent_at=' for #User:0x007fb78cfafb68 任何人都可以帮助我,因为我是Ruby on Rails的新手? 使用Devise恢复密码和向用户发送电子邮件的最佳方法是什么?非常感谢你…
我正在尝试使用设计恢复用户的密码,但它会生成以下错误
undefined method `reset_password_sent_at=' for #<User:0x007fb78cfafb68> 任何人都可以帮助我,因为我是Ruby on Rails的新手? 使用Devise恢复密码和向用户发送电子邮件的最佳方法是什么?非常感谢你… 我用的是装饰(2.2.3) User.rb require 'digest/md5' class User < ActiveRecord::Base # Setup accessible (or protected) attributes for your model belongs_to :shop before_create :compute_email_md5 # Include default devise modules. Others available are: # :token_authenticatable,:confirmable,# :lockable,:timeoutable and :omniauthable devise :database_authenticatable,:recoverable,:rememberable,:trackable,:validatable,:token_authenticatable # Setup accessible (or protected) attributes for your model attr_accessible :email,:email_md5,:password,:password_confirmation,:shop_id,:role,:terms,:name,:notify_on_order_received validates :terms,:acceptance => true,:on => :create end 解决方案是 解决方法
正如您所发现的,passord恢复要求模型具有reset_password_sent_at列.通过迁移添加它应该可以解决这个问题.
至于发生这种情况的原因,我猜你在最初生成启用Devise的模型(用户)之后添加了密码恢复(:可恢复模块).这就是为什么Devise的发生器没有为你创建那个专栏的原因. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |