Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


pluralize a little smarter #463

wants to merge 1 commit into from

5 participants

Mehul Kar Trek Glowacki Stefan Penner Tim Evans Tom Dale
Mehul Kar

No description provided.

Trek Glowacki

I almost wish we'd move RESTAdapter out of core or just label it as an example... but maybe I'm just bitter because my data needs are so crazy I can't use RESTAdapter

Mehul Kar

@trek I really like that idea actually. But if that were to happen a warning when starting the app would be nice.

Stefan Penner

@tim-evans i need to send a PR or make it a standalone plugin, but this might be useful.

Tim Evans

IMO, I'd make this a standalone plugin. SC does this ( I think the best approach would be to take the SC code and convert it to Ember code.

Tom Dale

Thanks for the pull request, but I'm going to have to decline this bad boy.

If we are going to do this, we should do it right and use a full-blown inflector library, like the one @stefanpenner mentioned above.

As much as I'd like to ship an inflector library with Ember, I think doing so would rank pretty high on the HHWWGT Index (How Hard Would We Get Trolled). We intentionally left this hook as dumb as possible so people will use something more appropriate for their needs.

There are some people who disagree with me, but whether it's built-in or available as a drop-in plugin, I think we need to use a battle-tested inflection library and not build it up ad-hoc.

Tom Dale tomdale closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 6, 2012
  1. Mehul Kar
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 1 deletion.
  1. +7 −1 packages/ember-data/lib/adapters/rest_adapter.js
8 packages/ember-data/lib/adapters/rest_adapter.js
@@ -271,7 +271,13 @@ DS.RESTAdapter = DS.Adapter.extend({
// define a plurals hash in your subclass to define
// special-case pluralization
pluralize: function(name) {
- return this.plurals[name] || name + "s";
+ var plural;
+ if (name.slice(-1) === 'y') {
+ plural = name.slice(0, -1) + "ies";
+ } else {
+ plural = name + "s";
+ }
+ return this.plurals[name] || plural;
rootForType: function(type) {
Something went wrong with that request. Please try again.