找不到嵌套的url:没有路由匹配的URL

时间:2013-04-09 11:35:27

标签: ember.js

Ember向我显示以下错误:未捕获错误:没有路由匹配网址'/ users'

Sks.IndexRoute = Ember.Route.extend
  redirect: ->
    this.transitionTo 'users'

Sks.Router.map ->
  this.resource 'users', path: 'users/:user_id'

Sks.UsersRoute = Ember.Route.extend
  setupController: (controller, model) ->
    this.controllerFor('users').set 'content', Sks.User.find()
    this.controllerFor('currentUser').set 'content', Sks.CurrentUser.find 1
    this.controllerFor('top').set 'content', Sks.Top.find()
    this.controllerFor('hamsters').set 'content', Sks.Hamster.find()

删除动态细分时,一切正常。

版本:v1.0.0-rc.1-78-gd4e6a5c

修改#1 添加了IndexRoute

2 个答案:

答案 0 :(得分:0)

在Ember中,收藏品和物品实际上使用不同的路线。我是这样做的:

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

App.IndexRoute = Ember.Route.extend({
    redirect: function () {
        this.replaceWith('contacts');
    }
});

App.ContactsRoute = Ember.Route.extend({
    model: function (params) {
        return App.Contact.find();  
    }
});

App.ContactRoute = Ember.Route.extend({
    model: function (params) {
        return App.Contact.find(params.contact_id);  
    }
});

这是working jsFiddle

答案 1 :(得分:0)

似乎我应该有RTM:)

Sks.Router.map ->
  this.resource 'users', ->
    this.resource 'user', path: ':user_id'