Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails gracefully handle timed out sessions?

Using rails 4, ruby 2.

I've set a timeout time of 30 minutes for my cookie session in the rails config. The problem is if I go to a form, let the session timeout, and then submit the form, I get this ActionController::InvalidAuthenticityToken error.

How do I gracefully handle this error in rails? Say, redirect to login screen?

like image 226
Derek Avatar asked Nov 19 '13 20:11

Derek


1 Answers

At your ApplicationController:

rescue_from ActionController::InvalidAuthenticityToken do 
  redirect_to some_path
end
like image 175
Maurício Linhares Avatar answered Oct 20 '22 21:10

Maurício Linhares