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 Data Challenge: Creating and Deleting Records

Link to Challenge: http://teamtreehouse.com/library/emberjs/ember-data/challenge-creating-and-deleting-records

Challenge Task 1 of 1

Update the NewKittenController controller to save a new Kitten in the Animal Shelter database.

Spent a lot of time looking for this one because 'NewKittenController' doesn't come up in a search of the forum..

The thread that gives a clue to the answer is this one: https://teamtreehouse.com/forum/save-button

..which has this line:

newPost.save();

What (you might ask) does this have to do with saving a new kitten - nothing, actually!

(that is what is so maddening about finding the answer to this challenge):

AnimalShelter = Ember.Application.create();

AnimalShelter.Router.map(function() {
  this.resource('kittens', {path: '/'});
  this.resource('kitten', {path: 'kittens/:kitten_id'});
});

var kittens = [
  {id: '1', name: 'Meowzer', cutenessRating: 2},
  {id: '2', name: 'Squeaky', cutenessRating: 3},
  {id: '3', name: 'Fluffy', cutenessRating: 1}
]

AnimalShelter.NewKittenController = Ember.Controller.extend({
  actions: {
    save: function() {
      var newKitten = this.store.createRecord('kitten', {
        name: this.get('name'),
        furColor: this.get('furColor')
      });
      // your code goes here
      newKitten.save();
      this.transitionToRoute('kittens');
    }
  }
});

See the line:

 newKitten.save();

--adding that line is all you need to pass.

Please don't waste as much time on this as I did. :wink:

By the way - despite the title of this challenge you learn NOTHING about deleting records, only creating new ones.