WARNING: Can't verify CSRF token authenticity
This warning appears while I'm trying to do jQuery ajax request.
I have faced this issue while upgrading my older rails app to rails 3.2.
This issue solved by adding bellow lines in head section in layout of application for me.
<%= csrf_meta_tag %>
<%= javascript_tag do %>
jQuery(document).ajaxSend(function(e, xhr, options) {
var token = jQuery("meta[name='csrf-token']").attr("content");
xhr.setRequestHeader("X-CSRF-Token", token);
});
<% end %>
The session was being reset in each ajax request (GET, POST, PUT, DELETE).
Adding the above mentioned code resolved my issue.
This warning appears while I'm trying to do jQuery ajax request.
I have faced this issue while upgrading my older rails app to rails 3.2.
This issue solved by adding bellow lines in head section in layout of application for me.
<%= csrf_meta_tag %>
<%= javascript_tag do %>
jQuery(document).ajaxSend(function(e, xhr, options) {
var token = jQuery("meta[name='csrf-token']").attr("content");
xhr.setRequestHeader("X-CSRF-Token", token);
});
<% end %>
The session was being reset in each ajax request (GET, POST, PUT, DELETE).
Adding the above mentioned code resolved my issue.