Gem rails 中使用 devise 的 lockable 问题

ailen · 2012年07月24日 · 最后由 goodboyRyan 回复于 2013年01月30日 · 3772 次阅读

今天在使用 rails 中的devise插件的locakable遇到了一个问题,我按照官方文档的配置如下: User.rb

class User < ActiveRecord::Base

  # Include default devise modules. Others available are:
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :confirmable, :lockable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me

end

然后在 db 中

......
 ## Lockable
       t.integer  :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
       t.string   :unlock_token # Only if unlock strategy is :email or :both
      t.datetime :locked_at
.......

按照这样的格式创建数据库。那么接下来怎么来实现 devise 的 lockable 的功能呢?

需要 登录 后方可回复, 如果你还没有账号请 注册新账号