Ember Data 1.0.0 Beta 5 RESTAdapter模型多元化

时间:2014-01-21 04:05:50

标签: javascript ember.js ember-data

我有以下配置:

window.App = Ember.Application.create();

DS.RESTAdapter.reopen({
    host: 'https://localhost:3000/api/v1',
});

App.Store = DS.Store.extend({
    revision: 11,
    adapter: DS.RESTAdapter
});

但我试图呼叫的网址是http://localhost:3000/api/v1/balance,但Ember最后称之为“余额”。有没有办法为此指定复数?谢谢!

1 个答案:

答案 0 :(得分:3)

这是旧的,应该删除,https://github.com/emberjs/data/blob/master/TRANSITION.md

App.Store = DS.Store.extend({
    revision: 11,
    adapter: DS.RESTAdapter
});

您可以像这样定义适配器

对于应用程序级适配器

App.ApplicationAdapter = DS.RESTAdapter;

对于特定型号适配器

App.BalanceAdapter = DS.RESTAdapter.extend({
  pathForType: function(type) {
    var decamelized = Ember.String.decamelize(type); 
    //return Ember.String.pluralize(decamelized);
    return decamelized;
  }
});