残り火のルートでスラッグ(モデルの属性)を使用して、よりクリーンなURLを取得する方法を理解しようとしています。
ルートは次のようになります。
http://www.server.com/#/newsitems/newsitem-title-in-slug-format/1
それ以外の:
http://www.server.com/#/newsitems/1/1
ご覧のとおり、ニュースアイテムのIDを実際のslug属性に置き換えたいと思います。Newsitem
モデルは次のようになります。
App.Newsitem = DS.Model.extend({
slug: DS.attr('string'),
title: DS.attr('string'),
summary: DS.attr('string'),
});
slugプロパティは、次の形式でクリーンテキスト属性を受け取ります。title-in-slug-format
これは現時点での私のルーターマップです。
App.Router.map(function(){
this.resource('newsitems', function(){
this.resource('newsitem', {path:':newsitem_id'});
});
});
で置き換えてみましたnewsitem_id
が、うまくいきnewsitem_slug
ません。他に何か提案はありますか?