2
我收到此錯誤路線:Ember.JS:沒有名爲嗒嗒
Assertion Failed: You attempted to define a `{{link-to "companies.show"}}` but did not pass the parameters required for generating its dynamic segments. There is no route named companies.show
但我確實有router.js
這條路線,並在工作之前,我添加了兩個新航線與編輯組件沿/添加記錄。但現在確實沒有了 - 我也可以直接導航到它。所以我認爲我在我的另一部分有一個錯誤,就是在我的路線上d d。
// router.js
Router.map(function() {
this.route('states');
this.route('companyTypes');
this.route('companies', function() {
this.route('show', {path: '/:company_id'});
this.route('new');
this.route('edit', {path: '/:company_id'});
});
this.route('counties', {path : '/counties/:state'});
});
// routes/companies.js
export default Ember.Route.extend({
model() {
return this.get('store').findAll('company');
}
});
// routes/companies/show.js
export default Ember.Route.extend({
model(params) {
return this.get('store').findRecord('company', params.company_id);
}
});
我正在傳遞link-to
中的模型參數,show路徑有它的模型掛鉤。
FYI:傳統的編輯路徑是'/:COMPANY_ID/edit' – dwenzel
@dwenzel,你的來源是什麼?我確實想按照正確的Ember慣例出門。我已經研究過的一個示例項目具有上述的編輯方式,但不能保證它們正確。 –
我認爲這只是一個REST API約定,儘管我找不到具體的源代碼。這似乎是合乎邏輯的:通常url就像一個嵌套的文件夾結構:'/ companies/edit ...'看起來像是在編輯所有公司,而'/ companies /:company_id/edit'看起來像是在編輯特定公司,這是你想要的。 – dwenzel