Skip to content

Instantly share code, notes, and snippets.

@leepfrog
Created December 14, 2012 09:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leepfrog/4284160 to your computer and use it in GitHub Desktop.
Save leepfrog/4284160 to your computer and use it in GitHub Desktop.
#EmberJS - Adding support for CSRF from Rails to your Adapter
App.Adapter = DS.RESTAdapter.extend
# Add CSRF Token from Rails to non-get requests
ajax: (url, type, hash) ->
if hash.data and type isnt "GET"
hash.data['authenticity_token'] = jQuery("meta[name='csrf-token']").attr("content")
@_super(url,type,hash)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment