mardi 24 mars 2015

Ember returning undefined for url parameter depending on the name of the parameter

I'm experiencing some weird behavior with a route parameter in Ember. It works depending on what the name of the route parameter is.


I have a router that looks like this



Router.map(function() {
this.resource('movies', { path: '/movies/:release_date' });
});


and a route that looks like this



export default Ember.Route.extend({
model: function(params) {
console.log('HI ' + Ember.keys(params) + ', ' + params.release_date);
return this.store.findAll('movie', params.release_date);
}
});


When I visit the route /movies/foo I see this in the console



HI release_date, undefined


However, if I change the param to almost anything other than release_date, it works as expected (i.e., change it in both the definition in the router and in the route object itself). Examples:



HI rel_date, foo
HI release_d, foo


Why does this happen? Is there any way to make it work with release_date as the parameter?





Aucun commentaire:

Enregistrer un commentaire