hasMany not updated only when changing the route


#1

Hi guys, I have a strange problem. Let’s say that I have two models post and comment. post has a hasMany relationship with comment. In the route posts/:id I can list all the comments correctly or apply to them pushObject / removeObject to add or remove comments but there’s a particular case in which this doesn’t work:

  1. If I remove one comment using removeObject (I keep that record in a service)
  2. then transit to posts
  3. then transit back to posts/:id
  4. and push the same comment with pushObject

The template doesn’t update with the old record and, if I repeat the step 2 and 3 again, the old comment appears again.

What could be the reason why the hasMany relationship doesn’t update in that particular case?


#2

Here’s a working example https://ember-twiddle.com/8cfcc43793b0ccafcd9e696546e06b71

I think that in ember-twiddle works because I’m using peekRecord and peekAll so my problem must be related with handling promises.