Last active
August 29, 2015 14:13
-
-
Save jrhe/ed430bf8a8cb9ea854c7 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
import DS from "ember-data"; | |
import ENV from "devon-discovery/config/environment"; | |
var ApplicationAdapter = DS.ActiveModelAdapter.extend({ | |
namespace: ENV.api.namespace, | |
headers: { | |
'Accept': 'application/json', | |
}, | |
serializePolymorphicType: function(record, json, relationship) { | |
var key = relationship.key; | |
var belongsTo = Ember.get(record, key); | |
var jsonKey = Ember.String.underscore(key + "_type"); | |
if (Ember.isNone(belongsTo)) { | |
json[jsonKey] = null; | |
} else { | |
json[jsonKey] = capitalize(camelize(belongsTo.constructor.typeKey)); | |
} | |
} | |
}); | |
export default ApplicationAdapter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment