Skip to content

Instantly share code, notes, and snippets.

@sankalpsingha
Created November 12, 2014 14:41
Show Gist options
  • Save sankalpsingha/ae219d8ee93754a1baff to your computer and use it in GitHub Desktop.
Save sankalpsingha/ae219d8ee93754a1baff to your computer and use it in GitHub Desktop.
This is the Ajax prefilter for Rails to be used for the CSRF with EmberJS
$(->
token = $('meta[name="csrf-token"]').attr('content')
$.ajaxPrefilter((options, originalOptions, xhr)->
xhr.setRequestHeader('X-CSRF-Token', token)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment