问题
These are the instructions to add a module to an existing Devise install: https://github.com/plataformatec/devise/wiki/How-To:-change-an-already-existing-table-to-add-devise-required-columns
But I can't seem to locate the necessary columns for timeoutable
.
I looked for the fields that timeoutable
requires in the Devise library: https://github.com/plataformatec/devise/blob/master/lib/devise/schema.rb - but there is no such method in that schema file.
The model just has a custom method with no reference to the columns: http://rdoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable
How do I add that functionality?
Thanks.
回答1:
timeoutable
refers to the login session timeout. No extra columns are needed, just add it to your model.
The timeoutable
hook contains all the magic (source: https://github.com/plataformatec/devise/blob/master/lib/devise/hooks/timeoutable.rb)
回答2:
You only need add timeoutable
to your user model:
devise :timeoutable
And set the interval time in 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
回答3:
Just add to your model:
devise :timeoutable, timeout_in: XX.minutes
replace XX with the number of minutes you want.
回答4:
timeoutable
not working if you are have remember_me = true
https://github.com/plataformatec/devise/blob/master/lib/devise/hooks/timeoutable.rb#L26
来源:https://stackoverflow.com/questions/7520195/how-do-i-add-devises-timeoutable-module-to-an-existing-devise-install-rail