Ember Router Error: "The contents of Ember.CollectionView must embed Ember.Array"

Ember's extremely straightforward question is here, (I hope so!).

I have a simple setup for Ember data. One application has many versions. Here is my application model:

App.App = DS.Model.extend({ name: DS.attr('string'), publicKey: DS.attr('string'), versions: DS.hasMany('App.Version', { key: 'version_ids' }) }); 

My router is pretty simple:

 App.Router = Ember.Router.extend({ location: 'hash', root: Ember.Route.extend({ index: Ember.Route.extend({ route: '/', redirectsTo: 'dashboard' }), dashboard: ..., app: Ember.Route.extend({ route: '/:app_id', connectOutlets: function(router, app) { router.get('applicationController').connectOutlet('appTest', app); }, index: Ember.Route.extend({ route: '/', connectOutlets: function(router) { appTestController = router.get('appTestController'); appTestController.connectOutlet('addCommentOutlet', 'addComment', {}); appTestController.connectOutlet('versions', appTestController.get('content.versions')); } }) }) }) }); 

Both views and controllers look like this:

 App.AppTestView = Ember.View.extend({ templateName: 'app_test' }); App.VersionsView = Ember.View.extend({ templateName: 'versions' }); App.AppTestController = Ember.ObjectController.extend({ }); App.VersionsController = Ember.ArrayController.extend({ }); 

When I run it, unfortunately, I get an error: an Ember.CollectionView content must implement Ember.Array. You passed <App.Version:ember519> an Ember.CollectionView content must implement Ember.Array. You passed <App.Version:ember519> .

Interestingly, if I add brackets around [appTestController.get('content.versions')] in the router, it will not complain and will correctly create an array with the first Version object. But it seems that he does not want to show more than one object.

Any tips?

+6
source share
1 answer

After all, these were not models, not objects or controllers! It was not even a router.

These were versions.handlebars . I had a loop in a loop in my template as shown below:

 {{#each version in controller}} Version here {{#each comment in version}} {{comment.text}} {{/each}} {{/each}} 

I wrote incorrectly:

 each comment in version 

... where I wanted to write:

 each comment in version.comments 

:) This explains the error message. Hope this helps someone else!

+11
source

All Articles