Skip to content

Instantly share code, notes, and snippets.

@cstengel88
Created October 1, 2015 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cstengel88/f331409e3fd7192428ce to your computer and use it in GitHub Desktop.
Save cstengel88/f331409e3fd7192428ce to your computer and use it in GitHub Desktop.
TypeError: Cannot read property 'map' of undefined
at json-serializer.js:584
at ext.js:497
at Map.forEach.cb (ember.debug.js:16815)
at OrderedSet.forEach (ember.debug.js:16614)
at Map.forEach (ember.debug.js:16819)
at Function.ember$data$lib$system$model$$default.reopenClass.eachRelationship (ext.js:496)
at ember$data$lib$system$serializer$$default.extend.extractRelationships (json-serializer.js:575)
at ember$data$lib$system$serializer$$default.extend.normalize (json-serializer.js:487)
at superFunction [as _super] (ember.debug.js:17013)
at ember$data$lib$serializers$json$serializer$$default.extend.normalize (rest-serializer.js:115)
} else if (relationshipMeta.kind === 'hasMany') {
data = relationshipHash.map(function (item) {
return _this4.extractRelationship(relationshipMeta.type, item);
});
}
relationshipHash == undefined
export default DS.Model.extend({
customer_group: DS.belongsTo('customer-group'),
position: DS.attr('number',{defaultValue: 0})
});
{
customer_groups: [{
customer_ids: [],
branch_opening_time_ids: [],
id: 30,
name: "XXX",
customer_group_id: 37,
change_date: "2015-03-19T00:00:00.000Z",
conflict: null,
updated: null,
created_at: "2015-03-20T09:11:32.000Z",
updated_at: "2015-03-20T09:11:32.000Z",
note: null
}, {
.
.
.
.
}],
dashboard_customer_groups: [{
id: 96,
position: null,
customer_group_id: 30
}, {
.
.
.
}
}]
}
export default DS.RESTSerializer.extend({
primaryKey: 'id',
normalize: function (type, hash, prop) {
hash.customer_group = hash.customer_group_id;
delete hash.customer_group_id;
return this._super(type, hash, prop);
},
serializeBelongsTo: function (record, json, relationship) {
this._super(record, json, relationship);
switch (relationship.key) {
case 'customer_group':
json.customer_group_id = json.customer_group;
delete json.customer_group;
break;
}
},
serializeIntoHash: function(hash, type, record, options) {
hash['dashboard_customer_group'] = this.serialize(record, options);
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment