MarcinPraski
MarcinPraski

Reputation: 24

Using ArrayController with multiple models

I have a Route which loads multiple models:

App.AppRoute = Ember.Route.extend({
  model: function() {
    return Ember.RSVP.hash({
          models1: this.store.find('model1'),
          models2: this.store.find('model2'),
          models3: this.store.find('model3'),
      })
  }
});

I want to extend the ArrayController for this page:

App.AppController = Ember.ArrayController.extend();

And the error is thrown:

Error: Assertion Failed: ArrayProxy expects an Array or Ember.ArrayProxy, but you passed object

My question is how to write a controller which can handle multiple model objects.

Upvotes: 1

Views: 148

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

Really an array doesn't make since. You have 3 different arrays.

So it would be an object controller, and you can access each item as an array in the application template or wherever it's appropriate.

App.AppController = Ember.ObjectController.extend();

Upvotes: 2

Related Questions