[英]How to make Ember data stop changing my endpoints to singular and plural according to its rules?
I need Ember to stop trying to guess things when making calls to the REST endpoints, but can't find a way do do so. 我需要Ember在尝试调用REST端点时停止尝试猜测,但是找不到解决方法。
If I have an endpoint say, /services
, I want ember to always call /services
regardless if I'm making a call to find('services')
or find('services', 1)
如果我有一个端点说
/services
,我希望ember总是调用/services
而不管我是在调用find('services')
还是find('services', 1)
Same for singulars. 同样的单数。
Is it possible to disable this behavior? 是否可以禁用此行为? Even if I have to override methods in the REStAdapter that'd be OK.
即使我必须重写REStAdapter中的方法也可以。
Thanks! 谢谢!
Sure, but you still should use find('service'). 可以,但是您仍然应该使用find('service')。
App.ServiceAdapter = DS.RESTAdapter.extend({
pathForType: function(type) {
var camelized = Ember.String.camelize(type);
return Ember.String.pluralize(camelized);
},
});
App.ServiceAdapter = DS.RESTAdapter.extend({
pathForType: function(type) {
var camelized = Ember.String.camelize(type);
return camelized; //Ember.String.pluralize(camelized);
},
});
App.BaseSingularAdapter = DS.RESTAdapter.extend({
pathForType: function(type) {
var camelized = Ember.String.camelize(type);
return camelized; //Ember.String.pluralize(camelized);
},
});
Both Foo and Bar would be singular using the code below 使用以下代码,Foo和Bar都将是单数
App.FooAdapter = App.BaseSingularAdapter;
App.BarAdapter = App.BaseSingularAdapter;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.