Reputation: 1478
I need to make timeout_in as dynamic value like below,But here self is not a instance of User model. can any one have idea how I can use that condition .
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable, :confirmable, :lockable, :timeoutable , :omniauthable,:timeout_in => (self.email.nil? ? 111.minutes : 112.minutes)
Upvotes: 1
Views: 860
Reputation: 2461
This feature is on Devise master and should be released on a new Devise version soon. You can point your Gemfile to Devise git repository and start using it right now.
https://github.com/plataformatec/devise/wiki/How-To:-Add-timeout_in-value-dynamically https://github.com/plataformatec/devise/pull/1462
Upvotes: 2
Reputation: 2461
I don't know if you can do that this way, since you are on a class scope.
To do what you want, define a method called timeout_in method that implements this logic. Because it has this method Devise tries to load timeout_in from an instance method, and after this it tries to get it from the class method.
EDIT: removed the monkey patch solution added a better one.
EDIT2: Improving the answer.
Upvotes: 0