Hi all, I’m lil bit confused on way how to load data from local storage. I have an app for displaying albums. So I have in application route:
App.ApplicationRoute=Ember.Route.extend({
model:function(){
return this.store.find('album');
},
That code makes GET request to my server, and receive Album model with bunch of relationship data. Than in nested routes in order to show data correctly I should do request again to ember data or use modelFor? For example in nested route \album\3\cover I have something like :
return this.modelFor('album').get('cover');
Or right way is to do request to store cover model again?
var coverId = this.modelFor('album').get('cover').get('id');
this.store.find('cover', coverId);
I will appriciate your help and explanation.
- Another question for example I would like to find all pages of some loaded album model (one-to-many relationship),
should I do something like
var albumId = this.modelFor('album').get('id');
var peters = this.store.find('pages', { album: albumId });
assuming that I have relationship for Album one to many and Pages model like this
App.Pages = DS.Model.extend({
album: DS.belongsTo('album')
});
OR there is some more ‘ember way’ approach? Many thanks in advance