ember.js - Ember RESTSerializer, relationships not behaving as expected -
i'm using both restadapter, , restserializer parse json payload relationships (sideloaded). docs ds.restadapter state sideloaded related data should returned under key of own type, e.g
{ "posts": { "id": 5, "title": "i'm running reform w3c's tag", "author": "yehuda katz", "comments": [1, 2] }, "comments": [{ "id": 1, "author": "user 1", "message": "first!", }, { "id": 2, "author": "user 2", "message": "good luck!", }] }
when using own payload, unless add type field each related item, parse error: 'cannot read property 'replace' of undefined'.
this payload:
{ "practice-items": [ { id: 1, title: 'major scales', discipline: 1 }, { id: 2, title: 'minor scales', total_issues_count: 5, discipline: 1 } ], "disciplines": [ { id: 1, title: 'scales', type: 'discipline' }, { id: 2, title: 'pieces', type: 'discipline' } ] }
this works - not if omit 'type' field in each related record. idea why - missing obvious?
i believe issue using key discipline
in each practice-items
, key sideloaded data disciplines
. need match, or – seeing – can use entirely different name specified type
attribute.
Comments
Post a Comment