Skip to content

Instantly share code, notes, and snippets.

@oniram88
Created June 9, 2013 13:07
Show Gist options
  • Save oniram88/5743448 to your computer and use it in GitHub Desktop.
Save oniram88/5743448 to your computer and use it in GitHub Desktop.
ExtJS - Ruby on Rails - WARNING: Can't verify CSRF token authenticity workaround to verify csrf token in every ajax request.
Ext.Ajax.defaultHeaders = {'Accept':'application/json'};
Ext.Ajax.on('beforerequest', function (o) {
var csrf = Ext.select("meta[name='csrf-token']").first();
if (csrf) {
o.defaultHeaders = Ext.apply(o.defaultHeaders || {}, {'X-CSRF-Token':csrf.getAttribute('content')});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment