Reference model inside template?

I have the following Route (simplified):

Spark.EntityListRoute = Ember.Route.extend({
      model: function() {
        var type = this.get("type");
        var promises = {
            model : this.store.find("game"),
        }
        return Ember.RSVP.hash(promises);  
      },
      setupController : function( controller, hash ) {
          controller.setProperties({
            model : hash.model,
          });
      },
      renderTemplate : function() {
        this.render("entityList");
      }
    });

And I’m trying to iterate over it’s model inside the template but it’s not working as expected.

<script type="text/x-handlebars" data-template-name="entityList">
    {{#each}}
       <li>{{name}}</li>
    {{/each}}
</script>

It looks ok. I think the convention is to assign the array (result from store.find) to the content property if you’ve extended ArrayController, rather than model. Last I checked though, one is aliased to the other, so it shouldn’t matter.

There’s a good deal of unnecessary indirection in your code example, so I’m assuming you elided some lines, though it’s common for newcomers to try to do a lot of things manually that Ember would otherwise do automatically. Maybe the issue is in the elided lines, or else the store/adapter is not finding any game records.

Here’s a basic working example: http://jsbin.com/fehayaza/51/edit

The problem was with that line. I suppose if you override the default template to say EntityList then it will also assume there’s an EntityListController.

I fixed it by specifying a controller name as well using:

this.render(“entityList”, {controller: “foo”});

There are plenty of omitted lines. For instance I’m extending EntityListRoute into a GameListRoute so I assumed it would look for GameListController. Since I changed it to use “entityList” in that line I guess it changed the default name again.

Good catch. I hadn’t used render before, but I’ll remember that, thanks.