Loading multiple models in a single route

@mikepmunroe Why use an ArrayController? I believe you can still iterate over the records in the {{#each}} without it. A simpler solution would be to use the ObjectController instead, as that will pass the users and tweets request directly to the model hash/object, eliminating the need for setupController().

app/routes/foo.js

App.FooRoute = Ember.Route.extend({
    model: function() {
        return Ember.RSVP.hash({
            users: this.store.findAll('user'),
            tweets: this.store.findAll('tweet')
        });
    }
});

app/controllers/foo.js

App.FooController = Ember.ObjectController.extend({});

app/templates/foo.hbs

<ul>
    {{#each users}}
        <li>{{name}}</li>
    {{/each}}
</ul>

<ul>
    {{#each tweets}}
        <li>{{content}}</li>
    {{/each}}
</ul>
7 Likes