Reputation: 37
i have a strange behavior:
If I call
this.store.find('uilabel', { locale: "en" });
it returns the result of /uielements?locale=en as I expect.
but if I add another parameter like
this.store.find('uilabel', { locale: "en", device: "mobile" });
I get this error:
Uncaught Error: Assertion Failed: Error: No model was found for 'device'
Ember correctly starts a GET-request to /uielements?locale=en&device=mobile which is responded
Does anyone know why this happens?
EDIT: Here is the uilabel-model. So far, it is as primitive as it could be :)
Application.Uilabel = DS.Model.extend({
locale: DS.attr('string'),
key: DS.attr('string'),
value: DS.attr('string'),
device: DS.attr('string'),
});
EDIT2: Sry, i could provide it by myself... here the JSON-response:
uilabels?locale=en&device=web
{
"locale": "en",
"device": "web",
"key": "server_url_dialog_default_button",
"value": "en_test"
}
Thanks
Upvotes: 0
Views: 69
Reputation: 3268
Your issue may be that the JSON response is not in the format that Ember Data is expecting. See http://emberjs.com/guides/models/connecting-to-an-http-server/. According to the spec, your JSON response needs to be in this format:
{
uilabels: [{
"locale": "en",
"device": "web",
"key": "server_url_dialog_default_button",
"value": "en_test"
}]
}
Since you're doing a this.store.find()
and passing multiple parameters, Ember Data is expecting an array of results versus just a single result. Hence, it is interpreting device
as an entire model, versus an attribute of uilabels
.
Upvotes: 1