Derek
Derek

Reputation: 12378

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?

Upvotes: 6

Views: 559

Answers (1)

Maurício Linhares
Maurício Linhares

Reputation: 40313

At your ApplicationController:

rescue_from ActionController::InvalidAuthenticityToken do 
  redirect_to some_path
end

Upvotes: 10

Related Questions