I'm very new in Ember world, and I'm struggling myself to make ember data work, but errors always happen.
I want get all my events with this.findAll('events');
in my events route, i already setup everything right i think.. but still not working.
Currently two errors is appearing.
1:
WARNING: Encountered "data" in payload, but no model was found for model name "datum" (resolved model name using SiteApp.ApplicationSerializer.modelNameFromPayloadKey("data"))
2:
Error while processing route: events Assertion Failed: You must include an 'id' for undefined in an object passed to 'push' Error: Assertion Failed: You must include an 'id' for undefined in an object passed to 'push'
I'm not getting where i'm messing up.
This is all i have:
Ember initialization.
window.SiteApp = Ember.Application.create({
LOG_TRANSITIONS: true
});
Configuration of RestAdapter and RestSerializer:
SiteApp.ApplicationAdapter = DS.RESTAdapter.extend({
namespace: 'api
});
SiteApp.ApplicationSerializer = DS.RESTSerializer.extend({
primaryKey: '_id'
});
Events router:
SiteApp.EventsRoute = Ember.Route.extend({
model: function() {
this.store.findAll('events');
}
});
Events model:
SiteApp.Events = DS.Model.extend({
_id : DS.attr(),
date : DS.attr(),
description : DS.attr(),
hiw : DS.attr(),
hour : DS.attr(),
meeting : DS.attr(),
men : DS.attr(),
name : DS.attr(),
title : DS.attr(),
women : DS.attr(),
created_at : DS.attr(),
is_active : DS.attr(),
updated_at : DS.attr()
});
So, when i access the route /api/events
, this is the JSON format that i'm going receive:
{
data: [{
_id: "55f660bdd80a0fd2e298f333",
title: "Pubx",
date: "2015-09-05T03:00:00.000Z",
created_at: "2015-09-14T05:53:01.292Z",
__v: 0,
updated_at: "2015-09-14T13:34:52.780Z"
}, {
_id: "55f660bdd80a0fd2e298f335",
title: "Pub",
date: "2015-09-05T03:00:00.000Z",
created_at: "2015-09-14T05:53:01.610Z",
__v: 0
}, {
_id: "55f660bdd80a0fd2e298f336",
title: "Pub",
date: "2015-09-05T03:00:00.000Z",
created_at: "2015-09-14T05:53:01.769Z",
__v: 0
}, {
_id: "55f660bdd80a0fd2e298f337",
title: "Pub",
date: "2015-09-05T03:00:00.000Z",
created_at: "2015-09-14T05:53:01.943Z",
__v: 0
}, {
_id: "55f6cc55f8aeb32de86a88e9",
date: "2015-09-15T00:00:00.000Z",
created_at: "2015-09-14T13:32:05.477Z",
__v: 0
}]
}
I already search a lot and i just cant figure out what is the problem here, i'm not seeing where is the problem.. :/
Thanks very much!
UPDATE:
I'm using:
"ember": "~2.0.2",
"ember-data": "~2.0.1",
"jquery": "^1.11.3"
Aucun commentaire:
Enregistrer un commentaire