Totally Confusing Framework


#1

Assertion failed: You must include an id in a hash passed to push

Well, let’s see.

App.NoteSerializer = DS.JSONSerializer.extend({
  primaryKey: '_id'
});


App.Note = DS.Model.extend({
  _id: DS.attr('string'),
  state: DS.attr('string')
});

Nope doesn’t work.

I’m working on.

DEBUG: Ember      : 1.3.1 ember.js:3285
DEBUG: Ember Data : 1.0.0-beta.6+pre.361a00e7
DEBUG: Handlebars : 1.3.0 ember.js:3285
DEBUG: jQuery     : 2.0.3 ember.js:3285

#2

We also try this but doesn’t work either.

App.NoteSerializer = DS.JSONSerializer.reopen({
  primaryKey: '_id'
});

#3

The first thing I can say is that you shouldn’t have an _id property in your Note model. The whole point of telling the serializer that your ID is named _id is so that it can convert it before it gets to the store. If everything works correctly, the _id property will never make it to your model.

About your assertion issue, you really have to provide us with more than that. The only thing I can say for sure is that the JSON passed to the push function doesn’t have an id property.

I would try debugging your code and see what the data variable contains in the push function. See if it contains _id instead of id. If it contains neither, maybe try placing a breakpoint in the normalizeId function of JSONSerializer, and see if it ever hits that point.


#4

I found out that my relations in the JSON document didn’t have ID’s thats why I always got that issue.