0
さ:Ember.Route - モデルのフックが、私は完全に正しいURLに不完全なURLをリダイレクトしたいと呼ばれる二回の代わりに、1
http://localhost/product/12/a-single-pr -> http://localhost/product/12/a-single-product-name
問題は、モデルのフックが二回の代わりに1のと呼ばれているということです1つのオブジェクトを検索する2つの同一の要求を行います。すべての手がかりは?
ルート/ product.js
import Ember from 'ember';
export default Ember.Route.extend({
afterModel(model, transition) {
let formatted = model.get('formatted');
if (transition.params.product.formatted !== formatted) {
let path = '/product/' + model.id + '/' + formatted;
this.replaceWith(path, model);
}
},
model(params) {
return this.get('store').findRecord('product', params.product_id);
}
});
router.js
...
Router.map(function() {
this.route('product', {path: '/product/:product_id/*formatted'});
});
...