I've seen the answer regarding changing the toJSON function in backbone to create a nested model Saving nested objects with Rails, backbone.js, and accepts_nested_attributes_for,
But I'm trying to understand why this works, and why it is any different than just creating
var book = new Book({title: 'my first book', chapters:[{chapter_title: 'first chapter'},{chapter_title: 'second chapter'}...]}); book.url ='books'; book.save();
I've been trying to save to rails using the manual method, but i can't save the chapters. I find this strange, as far as I can tell the json structure is there, so what does the 'to_JSON' change recommended for nested attributes do? Why is it necessary?
As backbone models don't need to have model attributes defined, will there be problems when a nested models is returned? Or will it just parse the entire json without issue?