I'm having some difficulty with the ember #each statement. I have a user who has a number of subjects associated with him, and I want to display these subjects in a list. This is what I have, but it doesn't render anything:
<script type = "text/x-handlebars" id = "user">
{{#if deleteMode}}
<div class="confirm-box">
<h5>Really?</h5>
<button {{action "confirmDelete"}}> yes </button>
<button {{action "cancelDelete"}}> no </button>
</div>
{{/if}}
<h3>Name: {{name}}</h3>
<h3>Email: {{email}}</h3>
<h3>Subjects:</h3>
<ul>
{{#each subject in this.user}}
<li>
{{subject.name}}
</li>
{{/each}}
</ul>
<button {{action "edit"}}>Edit</button>
<button {{action "delete"}}>Delete</button>
{{outlet}}
</script>
Here's my user model-
App.User = DS.Model.extend({
name: DS.attr('string'),
email: DS.attr('string'),
subjects: DS.hasMany('subject')
});
And my subject model-
App.Subject = DS.Model.extend({
name: DS.attr('string'),
users: DS.hasMany('user')
});
Any suggestions?