Jeff D
Jeff D

Reputation: 2175

BackboneJS and Rails 3 - Sync problems with $.ajax

I'm having trouble getting BackboneJS's syncing to work with my rails3 backend. I'm trying to use the JSON posts, and it sends my data in {_json: {}}. The problem with this is that the authenticity_token is then not included. (Or perhaps it is, but in the _json parameter). Rails won't deserialize it, even though I've forced the ajax options: {contentType: 'application/json', dataType: "json"}.

Any suggestions?

Upvotes: 1

Views: 502

Answers (2)

Joe W.
Joe W.

Reputation: 1452

Have you tried a before_filter that pulls the token out of request.parameters and sets it in the params hash?

Upvotes: 0

nicholaides
nicholaides

Reputation: 19489

Check out this adapter that incorporates Rails' authenticity token:

https://github.com/Maciek416/BackboneRailsAuthTokenAdapter

Source: Ed Schmalzle on the Philly.rb mailing list

Upvotes: 1

Related Questions