WARNING: Can’t verify CSRF token authenticity rails

I am sending data from view to controller with AJAXand I got this error:

WARNING: Can’t verify CSRF token authenticity

I think I have to send this token with data.

Does anyone know how can I do this ?

Edit: My solution

I did this by putting the following code inside the AJAX post:

headers: {
  'X-Transaction': 'POST Example',
  'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
},

17 Answers
17

Leave a Comment