这样做:
为User
模型创建一个名为is_active
的列.
然后将以下代码添加到User
型号:
class User < ActiveRecord::Base
#this method is called by devise to check for "active" state of the model
def active_for_authentication?
#remember to call the super
#then put our own check to determine "active" state using
#our own "is_active" column
super and self.is_active?
end
end
UPDATE
正如马特·哈金斯(Matt Huggins)所指出的,这种方法现在被称为active_for_authentication?
(Documentation)