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 trialSteven Byington
13,584 PointsWrong answer for model challenge
The challenge asks "We've set up a router with a couple resources for you, as well as a puppies variable with some model data. Create a puppy route that loads the correct puppy based on the ID in the URL."
Here is the answer I gave, but it says it is wrong. The alert says I need to pass the post_id into the second argument. Shouldn't it be puppies_id like I had put?
AnimalShelter = Ember.Application.create();
AnimalShelter.Router.map(function() {
this.resource('puppies', {path: '/'});
this.resource('puppy', {path: 'puppies/:puppy_id'});
});
var puppies = [
{id: '1', name: 'Miss Puggy'},
{id: '2', name: 'Pugsley Addams'},
{id: '3', name: 'Chicken Pug Pie'}
]
AnimalShelter.PuppyRoute = Ember.Route.extend({
model: function(params) {
return puppies.findBy('id', params.puppy_id);
}
});
5 Answers
Michael Kaiser-Nyman
Treehouse Guest TeacherHi Steven! Thanks for the heads up. Your solution is, indeed, correct. It looks like the challenge isn't set up properly. I've asked Treehouse to help out with getting that fixed. Thanks for finding the problem and pointing it out!
I hope you're enjoying the course so far.
Jolene Ross
7,311 PointsHere's the answer to the kittens question below:
Question: In app.js, we've set up a variable named kittens with some data in it. Set up KittensRoute to use this data for the model.
Answer:
AnimalShelter = Ember.Application.create();
AnimalShelter.Router.map(function() { this.resource('kittens', {path: '/'}); });
var kittens = [ {id: '1', name: 'Meowzer'}, {id: '2', name: 'Squeaky'}, {id: '3', name: 'Fluffy'} ]
AnimalShelter.KittensRoute = Ember.Route.extend({ model: function() { return kittens; } });
Kyle Meyer
5,459 PointsHey Steven Byington!
You're rightβwe had a bug in the code challenge. Your solution (the correct solution) is now properly accepted. Try again and all will be right in the world.
I also awarded you the Exterminator badge for being awesome and squashing bugs.
jadaml
11,593 PointsKyle Meyer It does not appear to be working yet. As my code below appears to be the same and is failing.
AnimalShelter.PuppyRoute = Ember.Route.extend({
model: function(params) {
return puppies.findby('id', params.puppy_id);
}
});
Ben Ackles
27,551 PointsI had the same result using the code examples from the video. The trick is to use findBy
instead of findby
.
Since this was from 3 months ago, I assume you figured it out by now. However, for anyone else that might be your problem.
james white
78,399 PointsSorry to hear you were having trouble jadami,
but Steven Byington's code worked for me.
Link to the challenge: http://teamtreehouse.com/library/emberjs/models/challenge-individual-objects