I have some JSON that has this structure in the /documents
path (the IDs are UUIDs):
{
\"tags\": [
{
\"id\": \"a33fc396-2428-11e3-
Because you already loaded all tags, and you don't want to send another request to /tags
. You can use store.all('tags')
, to get the already loaded tags:
App.DocumentsRoute = Ember.Route.extend({
model: function() {
var store = this.store;
return store.findAll('document').then(function(documents) {
// return an object with documents and tags, to be able to use both in the template
return {
documents: documents,
tags: store.all('tag') // to access all tags loaded in the payload we can just use store.all, so no additional request will be sent
}
});
}
});
And in your template:
{{#each documents}}
{{#each tags}}
Tags of that document
{{/each}}
{{/each}}
{{#each tags}}
All tags available
{{/each}}
You can see this in action in that fiddle http://jsfiddle.net/marciojunior/v4aZj/
Observation
In your payload you have tag_ids
this just work out of the box with ActiveModelAdapter
if you are using RESTAdapter
you need to change to tags
.