Skip to content

Instantly share code, notes, and snippets.

@ch3stnut
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ch3stnut/10363475 to your computer and use it in GitHub Desktop.
Save ch3stnut/10363475 to your computer and use it in GitHub Desktop.
Backbone._sync = Backbone.sync
Backbone.sync = (method, model, options) ->
if method is 'create' or method is 'update' or method is 'put' or method is 'delete'
options.headers ?= {}
options.headers["X-CSRF-Token"] = $("meta[name='csrf-token']").attr 'content'
return Backbone._sync(method, model, options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment