Created
October 1, 2015 13:42
-
-
Save cstengel88/f331409e3fd7192428ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default DS.Model.extend({ | |
customer_group: DS.belongsTo('customer-group'), | |
position: DS.attr('number',{defaultValue: 0}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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 | |
}, { | |
. | |
. | |
. | |
} | |
}] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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