batmanjs/batman — pull request #789 by nickjs (2013-08-08 20:33:12+00:00)
Title: Add ability to handle CSRF tokens in batman.rails.

Adds two config options:
- `protectFromCSRF`: false by default, unless you include batman.rails, in which case it's true by default.
- `metaNameForCSRFToken`: defaults to the name Rails uses for its meta tag, `csrf-token`

This includes support in the batman.rails extra for sending a CSRF token with any RailsStorage adapter requests. This allows batman-rails (or any batman.js app being used in a Rails environment) to automatically be able to send POST and PUT requests to the server, so long as a) they are on the same host and b) the page includes `<%= csrf_meta_tags %>`, which is the default. In other words, all requests will automatically work without any intervention from the user.

This is taken from Shopify, so it's tested as far as that goes, but I'd love ideas on how to write an actual test.

@SoapyIllusions @kristianpd @matthelm