Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not log out in rails with devise due to invalid authenticity token

So I'm stuck on this weird problem, which somehow I have never experienced before; and somehow I cannot find anything anywhere on how to solve it.

So my problem is this: When I'm logging out with this link

link_to "sign out", destroy_user_session_path, method: :delete

It crashes the application with this message

ActionController::InvalidAuthenticityToken in Devise::SessionsController#destroy 

The only other thing I have found here was that this says that someone has already logged out. However, this happens when I have not tried logging out before, nor has the time expired for the user to be logged in.

Is there anyone able to help me?

like image 208
Max Langerak Avatar asked Feb 10 '23 23:02

Max Langerak


1 Answers

The error indicates that the test for cross site request forgery is failing, because of an expired or missing csrf token.

It's worth checking that your layouts/application.html has the =csrf_meta_tag or <%= csrf_meta_tag %> as appropriate.

like image 127
SteveTurczyn Avatar answered Feb 23 '23 06:02

SteveTurczyn