hashg
hashg

Reputation: 806

EmberJS nested route not getting resolved

I am trying to construct a simple address book app in EmberJS.RC.1 build as part of learning it. My routes are not getting through the initial checks. What is the issue here? http://jsfiddle.net/Sz6fj/

Error in console:

Uncaught Error: assertion failed: Cannot call get with 'id' on an undefined object - ember-1.0.0-rc.1.js:52

structure

contacts
contacts/new
contacts/<id>
contacts/<id>/edit

Code:

App.Router.map(function(){
  this.resource('contacts', {path: '/'}, function(){
    this.route('new', {path: '/new'});
    this.resource('contact', {path: '/:contact_id'}, function(){
      this.route('edit', {path: '/edit'});
    });//contact
  });//contacts
});

Upvotes: 1

Views: 518

Answers (2)

Wildhoney
Wildhoney

Reputation: 4969

It's because you don't have a contact_id on the model. If you change it to the primary key (id) then it will work just fine: http://jsfiddle.net/Sz6fj/1/

contact_id does have a special usage on foreign keys.

Upvotes: 2

Alex Navasardyan
Alex Navasardyan

Reputation: 536

Try this:

App.Router.map(function(){
  this.resource('contacts', {path: '/'}, function(){
    this.route('new');
    this.resource('contact', {path: '/contacts/:contact_id'}, function(){
      this.route('edit');
    });
  });
});

Upvotes: -1

Related Questions