We are transitioning from Ember-Data pre 1.0 to 1.0. The guides are very clear regarding how to format JSON on the back-end when sending it to Ember. The fact Ember will only accept records with IDs also helps a lot to structure things.
But we are struggling with the other side of the problem: Ember to back-end. I understand it’s very much linked to the back-end used, but I was hoping someone could point me to a good (“definitive”?) guide covering the conventions used when interfacing with Rails + AMS.
Typical problem: model A has_many B.
- case 1: a new A is created in the client, and attached to a new B. We embed B into A’s payload and everything is fine.
- case 2: a new A is created in the client, and attached to an existing B. If we embed B into A’s payload, the server will not accept the payload (for security reasons). So it means in this case, we should only embed B’s id, not the whole record.
- case 3: a new A is created and linked to both an existing B, and to a newly created B. I don’t know how to handle this.
With multiple levels of relationships, it can become quite messy.
Is there a systematic, recommended way to handle this?