Ajax Delete links log out current_user

前端 未结 4 2492
自闭症患者
自闭症患者 2021-02-20 05:09

The title pretty much explains it. I\'m having an odd situation where views that allow users to delete notifications using Ajax cause the current_user to be logged out. I don\'t

相关标签:
4条回答
  • 2021-02-20 05:47

    I had a similar problem. Solution was as simple as adding

    <%= csrf_meta_tag %>

    to the layout.

    0 讨论(0)
  • 2021-02-20 05:56

    It turns out this had to do with changes to the Rails jQuery UJS driver and Devise. I had updated Devise without updating jQuery UJS -- and Devise was expecting the CSRF token to be handled differently, so it was processing the ajax request as unauthorized which meant destroying the current user's session. Upgrading to the latest jQuery Rails driver fixed the problem.

    0 讨论(0)
  • 2021-02-20 05:56

    Are you sure this controller and action are the ones that are triggered by the request? It sounds like the path you are DELETEing isnt right and you are hitting your sessions path instead.

    0 讨论(0)
  • 2021-02-20 06:03

    Is it possible that the destroy notification path is redirecting to the session destroy path through JS?

    Do you have destroy.js template in your notifications views? try adding one that is empty see if you get a different result.

    0 讨论(0)
提交回复
热议问题