[英]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.