如何覆盖设计可锁定模块 [英] How to override devise lockable module
本文介绍了如何覆盖设计可锁定模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图覆盖Lockable模块以支持devise-token-auth,但它没有覆盖。我到处搜寻,一无所获。我想我错过了一些东西,但我不知道。任何帮助将不胜感激
I tried to override Lockable module to support in devise-token-auth but it is not overriding. I searched on everywhere and found nothing. I think I missed something but I don't know what. Any help would be appreciated
module Lockable extends Devise::Models::Lockable
def valid_for_authentication?
# My code
end
end
推荐答案
拖放扩展
并将模块包含在您的设计模型中(用户,是吗?)
Drop that extends
and include the module in your devise model (User, is it?)
module MyLockable
def valid_for_authentication? # or whatever
...
end
end
class User
include MyLockable
end
或者您可以直接在用户中直接定义该方法。
Or you can simply define that method in the user directly.
class User
def valid_for_authentication?
...
end
end
这篇关于如何覆盖设计可锁定模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文