From 99c94e9c7b9c67bc52b76d4a77e60ac8f9271d62 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 10 Jul 2015 15:28:27 -0800 Subject: [PATCH] Clean up species id in strain serializer --- app/serializers/strain.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 app/serializers/strain.js diff --git a/app/serializers/strain.js b/app/serializers/strain.js new file mode 100644 index 0000000..9fd16c7 --- /dev/null +++ b/app/serializers/strain.js @@ -0,0 +1,13 @@ +import DS from 'ember-data'; + +export default DS.RESTSerializer.extend({ + isNewSerializerAPI: true, + + serializeBelongsTo: function(snapshot, json, relationship) { + var key = relationship.key; + var belongsTo = snapshot.belongsTo(key); + key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo", "serialize") : key; + json[key] = Ember.isNone(belongsTo) ? belongsTo : +belongsTo.record.id; + } + +});