You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Chris Habgood edited this page Aug 21, 2016
·
9 revisions
How To: Add timeout in value dynamically
This feature was added in version 1.5.2 and is not available in older versions of Devise
To dynamically set the timeout for each user, you can define a method in the user model called timeout_in that
returns the timeout value.
class User < ActiveRecord::Base
devise (...), :timeoutable
def timeout_in
return 1.year if admin?
1.days
end
end
timeout_in should return a integer with the number of
seconds (the timedout? method that devise uses, call the ago method on what timeout
returns). But of course, you can use Rails 10.seconds or 1.hour
to improve readability.