dantswain
dantswain

Reputation: 5467

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?

Upvotes: 0

Views: 183

Answers (1)

givanse
givanse

Reputation: 14963

Try:

rm -rf tmp/

And restart your server.

It is more likely to be a typo in your app than an Ember.js problem.

This works: http://emberjs.jsbin.com/pefudesaya/1/edit?html,js,console,output

Upvotes: 1

Related Questions