Skip to content

Upgrades Backbone's sync() to enable Rails3 + Backbone.js authenticity token passing

License

Notifications You must be signed in to change notification settings

Maciek416/BackboneRailsAuthTokenAdapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

If you are using Backbone.js with Rails 3 and are noticing that your authenticity token is not being passed in with Backbone's XHR calls, include this code and run it like so:

BackboneRailsAuthTokenAdapter.fixSync(Backbone);

The default method of operation assumes Rails' csrf_meta_tag call has already happened and that jQuery and Backbone are present. Thus it's best to run this code after Backbone, jQuery, and the metatag have been loaded but *before* your Backbone app makes its first request.

This code was adapted from:

http://www.ngauthier.com/2011/02/backbone-and-rails-forgery-protection.html

Thanks to Nick Gauthier ( @ngauthier )

About

Upgrades Backbone's sync() to enable Rails3 + Backbone.js authenticity token passing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published