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 trial

JavaScript

Ember.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
PLUS
Jeremy Faith
Courses Plus Student 56,696 Points

Change 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']);
    }
  }
});

Thank you, Jeremy. That worked.

That helped me too. Thanks!

Actually, 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']);
    }
  }
});

I 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']); } } });