I had a problem connecting the Json payload from Grape (serialized using the Grape object) with the Ember Reflective Model. The model is as follows:
Category = DS.Model.extend {
name: DS.attr 'string',
children: DS.hasMany 'category', inverse: 'parent',
parent: DS.belongsTo 'category', inverse 'children'
}
So, as you can see, I'm trying to model a category-subcategory relationship. Example json response from endpoint:
{
"category": {
"id": 1,
"name": "Sport",
"child_ids": [
5,
6,
8,
7
]
},
"children": [
{
"id": 5,
"name": "Basketball",
"parent_id": 1
},
{
"id": 6,
"name": "Football",
"parent_id": 1
},
{
"id": 8,
"name": "Running",
"parent_id": 1
},
{
"id": 7,
"name": "Volleyball",
"parent_id": 1
}
]
}
A warning message appears:
WARNING: Encountered "children" in payload, but no model was found for model name "child" (resolved model name using mateby-front@serializer:-active-model:.modelNameFromPayloadKey("children"))
As stated in the documentation for ActiveModelAdapter, it should provide identifiers for the embedded resource and an identifier for the parent resource with data loaded externally. The problem is that there is one category entry in the incubator-incubator, but without related children.
: /, , , hasMany ( ).