HasMany links breaks


#1

I have a situation with hasMany relationship in ember-data. I have a model called Book and that model has a hasMany relationship to a model Page which is fetch by “books/:id/pages”. The problem is that from the server I only receive an array with pages as img URL, without any extra data. Also the Book model doesn’t have any build in information about pages ids at all. For example, I receive something like this:

[ {thumb: ‘url/to/img.png’}, {thumb: ‘url/to/img.png’},{thumb: ‘url/to/img.png’} , … ,{thumb: ‘url/to/img.png’}]

After normalizing and all, I manage to get the pages rendered in the Books view successfully. BUT, only for the first load. Once I go away from the Books view, somehow Ember-Data looses the relationship between Book and Pages, so when I go back to the same view, the pages are not available for the Book model. I have tried to make an pages_ids attribute for the book model and set it as an array with the pages ids, but that doesnt seem to help.

Can somebody help me with this? It sounds like a very simple problem, but cant figure out how to solve it. I need a way to tell Ember-Data to save that relationship for the entire session, but cant find the right way to do that.

Any help is highly appreciated. Thanks in advance.