Skip to content

How to : Skip Devise Session Timeout for Other controller actions

Ilkham Gaysin edited this page Mar 29, 2021 · 4 revisions

In a scenario where the user need not be timed out when idle for more than the timeout period, Just add the code below to the controller for that action:

prepend_before_action(only: [:secure_redirect]) { request.env["devise.skip_timeout"] = true }

rails 6 try

prepend_before_action -> { request.env["devise.skip_timeout"] = true }, only: [:action]

I had to modify this slightly, for my needs, and I also skipped trackable. This meant when I visited another action which didn't skip timeout it got timed out as though the skipped page as not visited.

prepend_before_action :skip_timeout, only: [:show]

def skip_timeout

    request.env["devise.skip_trackable"] = true

    request.env["devise.skip_timeout"] = true

  end
Clone this wiki locally