Search code examples
ruby-on-rails-3ember.jsember-rails

why should I use 'plurals' in RESTAdapter


According to ember-part-2,

We should define the the plurals for model ? why ?

MVC's feature is convention over than configuration,

Why should I do it, and for what ?

app/assets/javascripts/models/store.js.coffee

DS.RESTAdapter.configure("plurals", entry: "entries")

Solution

  • Normally, you don't need to do this. Ember has an Inflector that can handle most pluralization.

    Ember.Inflector.inflector.pluralize('entry') === 'entries'
    

    If it doesn't, you can add your own:

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

    Ember Inflector is now a separate package and can be used outside of Ember: https://github.com/stefanpenner/ember-inflector