2014-11-05 81 views
1

我開始使用Ember使用ember-rails與Rails 4.1一起開發。爲什麼我的餘燼路由不被使用?

隨着定義了以下路線:

MyApp.Router.reopen({ 
    rootURL: '/mycontroller/' 
}) 
MyApp.Router.map() -> 
    this.route('welcome') 

當我訪問URL http://mysite/mycontroller/welcome,該welcome模板不渲染,但index之一。

DEBUG: ------------------------------- 
DEBUG: Ember  : 1.8.0 
DEBUG: Ember Data : 1.0.0-beta.11 
DEBUG: Handlebars : 1.3.0 
DEBUG: jQuery  : 1.11.1 
DEBUG: ------------------------------- 
Attempting URL transition to/
generated -> route:application Object {fullName: "route:application"} ember.js? body=1:15359 
generated -> route:index Object {fullName: "route:index"} 
Transition #0: application: calling beforeModel hook 
Transition #0: application: calling deserialize hook 
Transition #0: application: calling afterModel hook 
Transition #0: index: calling beforeModel hook 
Transition #0: index: calling deserialize hook 
Transition #0: index: calling afterModel hook 
Transition #0: Resolved all models on destination route; finalizing transition. 
generated -> controller:application Object {fullName: "controller:application"} 
Could not find "application" template or view. Nothing will be rendered Object {fullName: "template:application"} 
generated -> controller:index Object {fullName: "controller:index"} 
Rendering index with default view <(subclass of Ember.View):ember307> Object {fullName: "view:index"} 
Transitioned into 'index' 
Transition #0: TRANSITION COMPLETE. 

我的路線怎麼不明白?

回答

1

默認情況下,Ember路由期望在路由之前在您的URL中使用散列符號。要導航到您的welcome路線,該網址應該是http://mysite/mycontroller/#/welcome

如果你不喜歡這種行爲,它可以通過具有灰燼用瀏覽器的歷史API交互,像這樣被禁用:

App.Router.reopen({ 
    location: 'history' 
}); 

然後,您可以使用如預期的URL http://mysite/mycontroller/welcome

Here are the docs on Ember URL types

+0

太棒了。謝謝! – 2014-11-06 16:41:43