如何将Devise的’超时’模块添加到现有的Devise安装中? – 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
如何添加该function?
谢谢。
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替换为您想要的分钟数。
- Rails 4和Turbolinks – Meta标签不变
- 在部署到Heroku时,为什么Travis无法连接使用Redis cache_store?
- 使用AREL编写“不在”sql查询中
- Mysql import将timestamp空值转换为0000-00-00 00:00:00
- 如何将Hoptoad与DelayedJob和DaemonSpawn集成?
- 我的ActiveRecord模型的未定义方法“has_attached_file”
- validation失败时设计自定义消息
- Ruby on Rails:/ bin / sh:rspec:找不到命令
- TinyTds错误:Adaptive Server连接超时