In Ember data 0.13, pluralization was defined as follows:
DS.RESTAdapter.configure("plurals", {
category: "categories"
});
Configure no longer exists and thus there needs to be another way to define plurals.
By magic, it seems that if I do a find via "return this.store.find('category');", the JSON call includes /categories and not /categorys, although I have not at all specified that the plural of category is categories ...
How can Ember data determine this ? Is there a way to override ?
Thx
I'm using the following in app.js:
var inflector = Ember.Inflector.inflector;
inflector.irregular("patient", "patients");
I am not sure how to actually navigate to the REST adapter documentation anymore, but I recently updated the Pluralization Customization section with these examples:
Ember.Inflector.inflector.irregular('formula', 'formulae');
Ember.Inflector.inflector.uncountable('advice');
If the concern is to avoid the pluralization of the model name in the url only, you can override the pathForType function which is responsible of the transformation. It doesn't affect the pluralize function and finally it is a way of configuring the buildUrl process.
App.ApplicationAdapter = DS.RESTAdapter.extend({
namespace: 'rest/api',
pathForType: function(type) {
return (type);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With