I’m using backbone.js and it works great. but the forms I’m creating as a javascript template lacks the rails csrf protection token. How do I add it to templates I’m creating in javascript?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you have
<%= csrf_meta_tag %>in your layout somewhere and that is accessible to you from the js, then you can access it using$('meta[name="csrf-token"]')See http://eunikorn.blogspot.com/2011/07/working-with-backbonejs-in-harmony-with.html for an idea on how to hack in csrf support into each backbone request