简体   繁体   中英

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")

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM