Skip to content

Instantly share code, notes, and snippets.

@jrhe
Last active August 29, 2015 14:13
Show Gist options
  • Save jrhe/ed430bf8a8cb9ea854c7 to your computer and use it in GitHub Desktop.
Save jrhe/ed430bf8a8cb9ea854c7 to your computer and use it in GitHub Desktop.
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