2015-09-09 49 views
0
Router.map(function() { 
    this.resource('users', { path: '/stores/'+store_id+'/users' }); 
    this.route('user', { path: '/stores/'+store_id+'/users/:user_id'}, function() { 
     this.resource('devices', { path: '/devices' }); 
    }); 
}); 

在設備頁上我想回到/users/:user_id鏈接到餘燼中的上一個嵌套資源

這裏是我的template/devices.hbs

<table> 
    <tr> 
     <th>model</th> 
     <th>user_id</th> 
    </tr> 
    {{#each model as |device|}} 
    <tr> 
    <td>{{device.model}}</td> 
    <td>{{#link-to "???" ?? ???}}{{device.user_id}}{{/link-to}}</td> 
    </tr> 
    {{/each}} 
</table> 

我怎麼不回去的特定資源。

回答

1

使用user.index,因爲它是具有URL的完全合格路由名稱:/users/:user_id

{{#link-to 'user.index'}}Go back to /users/:user_id{{/link-to}} 

<table> 
    <tr> 
     <th>model</th> 
     <th>user_id</th> 
    </tr> 
    {{#each model as |device|}} 
    <tr> 
    <td>{{device.model}}</td> 
    <td>{{#link-to "???" ?? ???}}{{device.user_id}}{{/link-to}}</td> 
    </tr> 
    {{/each}} 
</table> 
+0

未被捕獲的錯誤完全合格的:沒有名爲回去/用戶/路線:USER_ID:/ – Mio

+0

{{#鏈接到「user.index」}}作品 – Mio

+0

以前的代碼應該也工作,但答案更新。 –

0

感謝@ daniel-kmak提示。這條路線是在user.index

<table> 
    <tr> 
     <th>model</th> 
     <th>user_id</th> 
    </tr> 
    {{#each model as |device|}} 
    <tr> 
    <td>{{device.model}}</td> 
    <td>{{#link-to 'user.index'}}{{device.user_id}}{{/link-to}}</td> 
    </tr> 
    {{/each}} 
</table>