這很簡單,可以更改適配器如何構建url。您只需擴展當前的適配器並覆蓋構建url的方法。在你的情況下,我設置了應用程序適配器(意味着它適用於所有類型)。當你提供一個特定的id
時,我並不確定如何構建url,但我確信這足以讓你開始,並且你可以從這個角度玩這個字符串操縱遊戲。
App.ApplicationAdapter= DS.RESTAdapter.extend({
pathForType: function(type) {
var camelized = Ember.String.camelize(type);
return camelized; //Ember.String.pluralize(camelized);
},
buildURL: function(type, id) {
var url = [],
host = Em.get(this, 'host'),
prefix = this.urlPrefix();
if (type) { url.push(this.pathForType(type)); }
url.push('list');
if (id) { url.push(id); }
if (prefix) { url.unshift(prefix); }
url = url.join('/');
if (!host && url) { url = '/' + url; }
return url;
}
});
實施例:http://emberjs.jsbin.com/OxIDiVU/690/edit