Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBlake Hutchinson
21,695 PointsEmber.js: Models: Challenge: ObjectController and ArrayController
http://teamtreehouse.com/library/emberjs/models/challenge-objectcontroller-and-arraycontroller
"In the Animal Shelter app, we've added a property to the kitten objects called cutenessRating. Make a KittensController that sorts the kittens by their cuteness by default."
Following the code I input for controllers/posts.js, I put in
// your code here
AnimalShelter.KittensController = Ember.ArrayController.extend({
actions: {
sortByCutenessRating: function() {
this.set('sortProperties', ['cutenessRating']);
}
}
});
I get an error message stating "Bummer! You need to set the sortProperties property within the controller."
Is this a bug or is there something incorrect in the code I put in?
3 Answers
Jeremy Faith
Courses Plus Student 56,696 PointsChange you sortByCutenessRating to sortByTitle. Before the actions label add the default 'sortProperties: ['cutenessRating'],'.
AnimalShelter.KittensController = Ember.ArrayController.extend({
sortProperties: ['cutenessRating'],
actions: {
sortByTitle: function() {
this.set('sortProperties', ['cutenessRating']);
}
}
});
Chris James
19,102 PointsActually, there is no need to change the function name to sortByTitle. Just set sortProperties as Jeremy suggests.
AnimalShelter.KittensController = Ember.ArrayController.extend({
sortProperties: ['cutenessRating'],
actions: {
sortByCutenessRating: function() {
this.set('sortProperties', ['cutenessRating']);
}
}
});
MUZ140970 Shaune Muringani
11,962 PointsI agree with Chris no need to sortByTitle this worked for me too; AnimalShelter.KittensController = Ember.ArrayController.extend({ sortProperties: ['cutenessRating'], actions: { sortByCutenessRating: function() { this.set('sortProperties', ['cutenessRating']); } } });
Blake Hutchinson
21,695 PointsBlake Hutchinson
21,695 PointsThank you, Jeremy. That worked.
Yuri Brunetto
1,892 PointsYuri Brunetto
1,892 PointsThat helped me too. Thanks!