I'm new to ember and am building a very simple app. I can navigate from my breeders index page(/breeders) to my breeders show page(/breeders/:breeder_id) by clicking on the link generated by the link-to tag. However if I manually navigate to breeders/1 or any of other breeders.show routes I get the following error:
Error while loading route: ReferenceError: params is not defined
at Catapp.BreedersShowRoute.Ember.Route.extend.model
I can't figure out what I've done that is causing this.
This is what I think is the relevant code:
//router.js
Catapp.Router.map(function() {
this.resource('breeders', function() {
this.route('new');
this.route('show', {path: '/:breeder_id'});
});
});
Catapp.IndexRoute = Ember.Route.extend({
redirect: function(){
this.transitionTo('breeders.index');
}
});
Catapp.BreedersIndexRoute = Ember.Route.extend({
model: function(){
return this.store.find('breeder');
}
});
Catapp.BreedersShowRoute = Ember.Route.extend({
model: function(){
return this.store.find('breeder', params.breeder_id);
}
});
.
// breeders_controller.js
Catapp.BreedersController = Ember.ArrayController.extend({
sortProperties: ['id']
});
You'll need to actually add the argument to the model hook
Catapp.BreedersShowRoute = Ember.Route.extend({
model: function(params){
return this.store.find('breeder', params.breeder_id);
}
});
You can call it whatever you like as well
Catapp.BreedersShowRoute = Ember.Route.extend({
model: function(foo){
return this.store.find('breeder', foo.breeder_id);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With