Backbonejs and rails issues w/ Backbone.sync

54 wyświetlenia
Przejdź do pierwszej nieodczytanej wiadomości

Jeff Deville

nieprzeczytany,
31 sie 2011, 07:48:1731.08.2011
do PhillyRB

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"}.

I posted the question to stack overflow here, if you'd like to bump up your rep, I'll gladly upvote.

http://stackoverflow.com/questions/7256232/backbonejs-and-rails-3-sync-problems-with-ajax

-Jeff

Ed Schmalzle

nieprzeczytany,
31 sie 2011, 07:50:3431.08.2011
do phil...@googlegroups.com
Hey Jeff,

If the authenticity token is your problem, this will fix it: https://github.com/Maciek416/BackboneRailsAuthTokenAdapter

- Ed
--
You received this message because you are subscribed to the Google Groups "Philly.rb" group.
To post to this group, send email to phil...@googlegroups.com.
To unsubscribe from this group, send email to phillyrb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/phillyrb?hl=en.

Jeff Deville

nieprzeczytany,
31 sie 2011, 12:13:1031.08.2011
do phil...@googlegroups.com, phil...@googlegroups.com
Hi Ed, thanks but that was not the problem. Or rather, that doesn't fix it when you are not in emulateHTTP mode, because backbone sticks the JSON doc in a param called _json. The auth token is in there but rails isn't pulling it out

Grant Ammons

nieprzeczytany,
1 wrz 2011, 08:26:591.09.2011
do phil...@googlegroups.com
Sounds to me like something else is going on. We use Backbone heavily here at
PipelineDeals and I have not run into a case where Backbone sends data inside of a hash entry _json.

Where does _json get generated?

-Grant

In-Reply-To: <4FDE4CC5-0324-41C8...@gmail.com>

* Jeff Deville <jeffd...@gmail.com> [2011-08-31 12:13:10 -0400]:

Jeff Deville

nieprzeczytany,
1 wrz 2011, 09:24:081.09.2011
do phil...@googlegroups.com
Hi Grant,
I'm not using most of Backbone, just the Sync component (I'm mixing and matching a few frameworks), and was calling in to it myself. I think the problem was that I wasn't stringifying the JSON. Once that didn't work, I started messing with $.ajax options extensively, and went down a rabbit hole.

I got things working now though. Thanks.

-Jeff

Odpowiedz wszystkim
Odpowiedz autorowi
Przekaż
Nowe wiadomości: 0