[英]How do I add Devise's 'timeoutable' module to an existing Devise install? - Rails 3.1
这些是将模块添加到现有Devise安装的说明: https : //github.com/plataformatec/devise/wiki/How-To :-change-an-already-existing-table-to-add-devise-required -列
但我似乎无法找到可timeoutable
的必要列。
我查找了Devise库中可timeoutable
的字段: https : //github.com/plataformatec/devise/blob/master/lib/devise/schema.rb - 但该模式文件中没有这样的方法。
该模型只有一个自定义方法,没有引用列: http : //rdoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable
如何添加该功能?
谢谢。
timeoutable
是指登录会话超时。 不需要额外的列,只需将其添加到您的模型中即可。
timeoutable
挂钩包含所有魔法(来源: https : //github.com/plataformatec/devise/blob/master/lib/devise/hooks/timeoutable.rb )
您只需要为用户模型添加timeoutable
:
devise :timeoutable
并在config/initializers/devise.rb
设置间隔时间:
# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
# time the user will be asked for credentials again. Default is 30 minutes.
config.timeout_in = 30.minutes
只需添加到您的模型:
devise :timeoutable, timeout_in: XX.minutes
将XX替换为您想要的分钟数。
如果你有remember_me = true
则timeoutable
不工作
https://github.com/plataformatec/devise/blob/master/lib/devise/hooks/timeoutable.rb#L26
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.