Created
February 1, 2012 17:03
-
-
Save coffeencoke/1718055 to your computer and use it in GitHub Desktop.
Session clears when making ajax requests in Rails 3.0.4+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajaxSetup({ | |
beforeSend: function(xhr) { | |
xhr.setRequestHeader('X-CSRF-Token', $("meta[name='csrf-token']").attr('content')); | |
}} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use this if you are getting issues with your session clearing when making ajax requests. In previous rails versions you would receive invalid session authenticity token, but now, it just clears the session silently and slyly.