17

I have a model type that ends in -y: Security

How do I tell Ember Data to use /securities instead of /securitys to find resources for this?

outside2344
  • 2,075
  • 2
  • 29
  • 52

3 Answers3

18

Adding a hash to the create method doesn't seem to work with the latest version of Ember Data. I got the RESTAdapter.configure method to work as expected using the suggestion in this ticket: https://github.com/emberjs/website/pull/218 .

DS.RESTAdapter.configure("plurals", { person: "people" });
App.Store = DS.Store.extend({
  revision: 11,
  adapter: DS.RESTAdapter.create({
    namespace: 'api'
  })
});
willimus
  • 241
  • 2
  • 3
17

After digging around in the Ember Data sources, what you need to do is add a hash to your create of DS.RESTAdapter, ala:

App.store = DS.Store.create({
  adapter: DS.RESTAdapter.create({ bulkCommit: false,
                                   plurals: {"security": "securities"} }),
  revision: 4
});
outside2344
  • 2,075
  • 2
  • 29
  • 52
13

This is the most relevant for pluralization as of ED 1.0.0-beta

With ember-data beta and up you can define irregular and uncountable pluralizations like this:

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

Example:

import DS from 'ember-data';
import Ember from 'ember';

var ApplicationAdapter = DS.RESTAdapter.extend({
  namespace: 'api'
});

var inflector = Ember.Inflector.inflector;
inflector.uncountable('advice'); //only makes call to /advice

export default ApplicationAdapter;
dasnixon
  • 988
  • 7
  • 18
Willem de Wit
  • 8,604
  • 9
  • 57
  • 90