Question

I am using ember appkit for a beginner ember project. I am working with an existing API and my model looks as such:

export default Ember.Route.extend({
model: function(){
    return this.store.find('prequalification');
}

});

When the API call happens, the URL is pluralized, prequalifications. I am trying to configure the RestAdapter but not sure where in the code flow this should happen.

Thanks for any help

Was it helpful?

Solution

Irregular or uncountable pluralizations can be specified via Ember.Inflector.inflector:

Ember.Inflector.inflector.irregular('formula', 'formulae');
Ember.Inflector.inflector.uncountable('advice');

This will tell the REST adapter that requests for App.Formula requests should go to /formulae/1 instead of /formulas/1.

REF : http://emberjs.com/guides/models/the-rest-adapter/#toc_pluralization-customization

OTHER TIPS

It happens in the RestAdapter, you're correct...

check the pathForType attribute out out:

https://github.com/emberjs/data/blob/v1.0.0-beta.6/packages/ember-data/lib/adapters/rest_adapter.js#L476

Their example is:

DS.RESTAdapter.reopen({
  pathForType: function(type) {
    var decamelized = Ember.String.decamelize(type);
    return Ember.String.pluralize(decamelized);
  };
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top