解决方法
您应该使用
Timeoutable
型号特征.
Timeoutable takes care of veryfing whether a user session has already expired or not. When a session expires after the configured time,the user will be asked for credentials again,it means,he/she will be redirected to the sign in page.
Options
Timeoutable adds the following options to devise_for:
- +timeout_in+: the interval to timeout the user session without activity.
在你需要的模型中
devise :timeoutable # along with :database_authenticatable,:registerable and other things.
另外,看一下config / initializers / devise.rb,你可以在那里配置超时值.