0

If I set remote: true to my form authenticity_token disappear. I have to add authenticity_token: true to my form? What about caching? If I cache the form I have to add authenticity_token: true? Is a problem that authenticity_token is cached? Thank you

Mr McDonald
  • 453
  • 7
  • 16

1 Answers1

0

Are you using the jquery-rails gem in your app? This'll add the CSRF token to remote: true AJAX form submissions automagically:

https://github.com/rails/jquery-rails/blob/master/vendor/assets/javascripts/jquery_ujs.js#L69

// Make sure that every Ajax request sends the CSRF token
CSRFProtection: function(xhr) {
  var token = rails.csrfToken();
  if (token) xhr.setRequestHeader('X-CSRF-Token', token);
}
calebkm
  • 1,013
  • 4
  • 17