I have 3 models in a hasMany chain. E.G. Gallery -> Image -> Comment
Returning both the selected Gallery and the Images in it in a single json response works as expected. The backend is a Rails app using active_model_serializers, btw.
{"images":[...],"galleries":{"id":1,...,"images":[1,2,3]}}
But when I tell the serializer about the Comments and they get included in the json I get a mapping error from Ember.
{"comments":[...],"images":[...],"galleries":{"id":1,...,"images":[1,2,3]}}
Error: assertion failed: Your server returned a hash with the key comments but you have no mapping for it
I can't figure out how to properly tell Ember how to handle this. My debugging suggests that Anything in the json response has to be directly referenced in the Gallery model. I have tried adding a "mapping" to the RESTAdapter using both the singular and plural forms just to be sure. "comments: App.Comment" or "comment: App.Comment" makes no difference I can see.
I suppose I could give up and just do a few more requests but since the Comments are always used when a given Image is used, it feels wrong. I'd love some help figuring our how to allow the data in a single response.
Do I need to completely re-configure the serializers and Ember to embed the data instead of referencing them with IDs?
chers, Martin
(Note: The model names are fictive to make them more generally understandable compared to the fun domain I am actually modeling)