2013-06-23 47 views
0

我最近发布了一个问题,解决了here关于访问Rails关系的问题。答案效果很好,嵌入记录对任何单层嵌套属性都能正常工作(预览问题中的示例是1个群组有很多引导)。在Ember中嵌入记录嵌套2层

我无法工作的是添加第二层嵌套(一个队列有许多靴子,每个都有许多集线器)。我在store.js.coffee文件中有以下扩展名。

Plato.Adapter = DS.RESTAdapter.extend() 

Plato.Store = DS.Store.extend(adapter: Plato.Adapter) 

Plato.Adapter.map "Plato.Cohort", 
    boots: 
    embedded: "always" 

Plato.Adapter.map "Plato.Boot", 
    hubs: 
    embedded: "load" 

有没有一种简单的方法来实现这个(即上面的代码不起作用)?我跑过

的一个问题是在我的控制台,当我运行

var hub = App.Hub.find(1) 

我收到以下错误

Failed to load resource: the server responded with a status of 404 (Not Found) 
http://localhost:3031/hubs/1 

当我的余烬路由如下

App.Router.map()-> 
    this.resource('cohorts', -> 
     this.resource('cohort', {path: '/:cohort_id'}, -> 
     this.resource('boot', {path: '/boots/:boot_id'}, -> 
       this.resource('hub', {path: '/hubs/:hub_id'}) 
    ) 
    ) 
) 

和我的导轨路由器是

resources :cohorts do 
    resources :boots do 
     resources :hubs 
    end 
    end 

任何想法为什么它默认为标准的非嵌套路线?

回答

1

尝试从嵌套的路径路径中删除/前缀。

App.Router.map()-> 
    this.resource('cohorts', -> 
    this.resource('cohort', {path: ':cohort_id'}, -> 
     this.resource('boot', {path: 'boots/:boot_id'}, -> 
     this.resource('hub', {path: 'hubs/:hub_id'})