Backbone.js and Rails - How to handle params from Backbone models?

It's nice when you can have the general Rails forms and Backbone forms match with respect to the root node. That's why in my last application I chose to override the Backbone models' toJSON method.

It's nice when you can have the general Rails forms and Backbone forms match with respect to the root node. That's why in my last application I chose to override the Backbone models' toJSON method. You could override the global toJSON method as Raimonds Simanovskis suggested.

But even the non-DRY way approach isn't so bad. Just one line of boilerplate for each model definition: // Depends on Underscore. Js User = Backbone.Model.

Extend({ toJSON: function() { user: _. Clone({ this. Attributes }) }, // Your other methods here }); Edit: Corrected code sample.

Sorry for the errors, I was translating from CoffeeScript to JavaScript.

1 I've accepted this answer because it's pretty much on the money, but I decided to just handle this on the server side. – Brian Hogan Aug 5 at 5:55.

In one of the answers to Rails mass assignment and Backbone. Js there is mentioned patch https://gist.github. Com/719080 which I think will do what you need.

I have made a little hack to namespace save requests under model. Name property. It monkey patches toJSON() during sync() call only and restores original method so you can use it as usual.

I have implemented it in CoffeeScript. Check it here: https://gist.github. Com/1128000.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions