做了三件事:
确保Devise集成在" routes.rb"
中devise_for :accesses
模型中的集成设计" access.rb"
class Access < ActiveRecord::Base
include UUIDHelper
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
belongs_to :verification
belongs_to :actor, autosave: true
validates_presence_of :username
validates :username, uniqueness: true
validates_length_of :username, maximum: 64
validates_length_of :username, minimum: 3
# Returns the hash digest of the given string. Used for SEEDS FILE
def Access.digest(string)
cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :
BCrypt::Engine.cost
BCrypt::Password.create(string, cost: cost)
end
end
在&#34; access_controller.rb&#34;
中重置密码的命令 def recoverAccount
myAccess = Access.find_by email: params[:access][:email]
myAccess.send_reset_password_instructions
end
&#34; send_reset_password_instructions&#34;和Devise的其他方法抛出一个未定义的方法;我做错了什么?我错过了什么?
编辑:
我刚想出一些新的东西; #before_filter:authenticate_user!不起作用;我进行了正确的安装,但我不知道它为什么不起作用。