Reputation: 91
I have an ember application with a model named "media". "media" is a singular word. "medias" is the plural one. I define my model like this :
App.Media = DS.Model.extend({
name: DS.attr('string')
});
Normally, "media" is the singular name of my model. So my api return this payload executing this.store.find('media', 1)
:
{
"media": {
"id" : 1,
"name" : "media name"
}
}
This give me an error: No model was found for 'medium'
.
Ember-data want me to return a payload like this: { "medium": {...}}
.
Why does enber-data singularize "media" ? It's already a singular word.
Moreover, adding irregular rule to the inflector don't affect the adapter at all.
Ember.Inflector.inflector.irregular('media', 'medias');
A complete example can be found here : http://emberjs.jsbin.com/bobaj/5/edit?js,output
Upvotes: 0
Views: 272
Reputation: 91
This solves my problem:
Ember.Inflector.inflector.singular(/([ti])a$/i, '$1a');
Ember.Inflector.inflector.plural(/([ti])a$/i, '$1as');
Upvotes: 0