With the following code, you can return multiple models (assuming you've previously fetched your data):
model: function() {
return Ember.RSVP.hash({
cars: this.store.peekAll('car'),
owners: this.store.peekAll('owner'),
parts: this.store.peekAll('part')
});
}
And then you can display them:
<br>
etc etc.
Find a specific car record is easy enough:
model: function(params) {
return this.store.peekRecord('car',params.car_id);
}
How would one find a specific car record while at the SAME TIME load in all of the owners to the page?
Something like this does not seem to work when you hit this url for example: /car/1
model: function(params) {
return Ember.RSVP.hash({
cars: this.store.peekRecord('car',params.car_id),
owners: this.store.peekAll('owner'),
parts: this.store.peekAll('part')
});
}
You could argue to use belongsTo or hasMany... however the parts or owners are NOT assigned to the car record yet, they are simply needed on the page, so the user can assign multiple owners or parts to one car if they decide to do so.
Aucun commentaire:
Enregistrer un commentaire