Skip to content

Instantly share code, notes, and snippets.

@vladimir-e
Created May 5, 2014 16:10
Show Gist options
  • Save vladimir-e/11540982 to your computer and use it in GitHub Desktop.
Save vladimir-e/11540982 to your computer and use it in GitHub Desktop.
Add CSRF token to request headers when using JS framework with rails
$ ->
token = $('meta[name="csrf-token"]').attr('content')
$.ajaxPrefilter (options, originalOptions, xhr) ->
xhr.setRequestHeader('X-CSRF-Token', token)
@vladimir-e
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment