Configuring plurals of model names in Ember Data

by Kasper Tidemann

Expressing different grammatical categories is called inflection. In software development, inflection libraries such as fleck by Trek Glowacki will help automate the process of converting singulars to plurals and vice versa – something that comes in handy when adding or removing a plural s just doesn’t apply.

Say you have a model named App.Activity. Out of the box, the DS.RESTAdapter in Ember Data will map this model to /activitys on the server which is clearly wrong, since the plural form of the word activity is activities.

An up-to-date way of handling this is to configure your Ember Data adapter like so:

App.Adapter.configure('plurals', {
  activity: 'activities'
});

So, instead of including an entire inflection library in Ember.js, the core team has made it up to you to provide proper inflection where necessary. Luckily, given the above example, it couldn’t be much easier to configure.