Reputation: 491
Say I have a DS.Store model called "userPreferences". Say I have a backend API returning a SINGLE "userPreferences" record:
{"userPreferences":{"userID":"7","latitude":null,"longitude":null}}
Say I have a route that I want to use this model with:
App.SettingsRoute = Ember.Route.extend({
model: function() {
myModel = this.store.find('userPreferences', 7);
return myModel;
}
});
If I try to do this, I get the following error from ember:
Error: No model was found for 'userPreference'
How do I specify that I'm already returning the singular form?
Upvotes: 0
Views: 217
Reputation: 2576
If you don't ever plan to refer to a collection of userPreferences, as Steve H. suggested you might need to, you can define the phrase as uncountable:
Ember.Inflector.inflector.uncountable('userPreferences');
Just be careful, you might need to also define:
Ember.Inflector.inflector.uncountable('user_preferences');
Because at present the inflector doesn't assume that you want both defined. The underscore version is sometimes used by ember-data when referring to model properties during serialization. I always define both camelCase and underscore versions.
I've opened an issue about this on ember-inflector.
Upvotes: 1
Reputation: 6947
What do you plan to call a collection of userPreferences
? Here, I'm calling them "manyUserPreferences", but I'd suggest something better :) You can customize the way Ember understands the model names using an Inflector
:
Ember.Inflector.inflector.irregular('userPreferences', 'manyUserPreferences');
Upvotes: 0