I have an array of objects from my controller. I can display the properties but the linkTo object is not being set
Im also using ember-model not ember-data
Msmapp.ClassroomsRoute = Ember.Route.extend({
model: function() {
return Msmapp.Classroom.findAll(); //Ember.Model
}
});
Msmapp.Classroom = Msmapp.Model.extend({
classroom_id: Ember.attr('number'),
classroom_name: Ember.attr('string'),
teacher_id: Ember.attr('number'),
grade: Ember.attr('number'),
students: Ember.attr('string'),
assignments: Ember.attr('string'),
classroomStudents: function () {
var studentObjects = []
this.get('students').forEach(function(student) {
studentObjects.push(Msmapp.Student.create(student));
});
return studentObjects;
}.property('students')
});
Msmapp.Classroom.reopenClass({
collectionKey: "classrooms",
url: '/classrooms'
});
{{#each classroom in controller }}
<li class="item">
{{#linkTo 'classroom' classroom }}{{ classroom.classroom_name }}{{/linkTo}}
</li>
{{/each}}
The classroom.classroom_name work just fine. I have even changed it to a computed property.
But the link is not setting the model. Its a nested route.
im getting /classrooms/undefined
The odd thing is when i click the link, it populates the classroom model and view.
My route
this.resource('classrooms', function() {
this.resource('classroom', {path: ':classroom_id'}, function() {
this.route('new_student');
});
this.route('new');
});
note: if i change the :classroom_id to just :id i get back something like this
/classrooms/<Msmapp.Classroom:ember403>
I just switched from ember-data to ember-model so im sure its something trivial im overlooking.