Let's say I have two models, Topic and Post :
App.Topic = DS.Model.extend({ posts: DS.hasMany('post', { async: true, inverse: 'post' }); }); App.Post = DS.Model.extend({ topic: DS.belongsTo('topic', { async: true }); });
hasMany Theme Messages and the message belongsTo a Topic.
To load data from the API, one initial call is made (which selects the topic ... topic ID 2, for example): GET /topics/2
After receiving the payload for this GET request, the serializer then adds the links key to the payload. This has a way to download messages related to the topic:
"topic": { "id": 2, "links": { "posts": "/topics/2/posts" } }
This second request (before /topics/2/posts ) is how posts are downloaded and attached to the topic.
All this works great the first time the page loads.
The problem occurs when Post is created during a page session . Although I can get this theme to reload (by calling .reload() on the model object that represents the theme), the Posts associated with the theme do not reload. The second API call (to receive messages) is never made, while the first call (to receive only the topic) is made. If I refresh the page, the messages created by me on the previous page load will be downloaded (but, of course, if I go over and make a few more messages, they will not appear until the next page loads).
Looking for a solution, I came across this question: How to reload asMynchronous communication with hasMany links?
However, it seems that the solution no longer works for current versions of Ember / Ember-Data. Provided by JSFiddle does not work.
So, how can I reload this kind of hasMany relationship? Any help is appreciated.