-
Notifications
You must be signed in to change notification settings - Fork 5.5k
How To: Add timeout_in value dynamically
François Ferrandis edited this page Jan 27, 2023
·
11 revisions
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.day
end
endtimeout_in should return a integer with the number of
seconds (the timedout? method that devise uses calls the ago method on what timeout_in
returns). Of course, you can use Rails 10.seconds or 1.hour to improve readability.