Serialized hasMany
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
App.ApplicationSerializer = DS.ActiveModelSerializer.extend({ | |
serializeHasMany: function(record, json, relationship) { | |
var key = relationship.key; | |
var json_key = key.singularize().decamelize() + '_ids'; | |
var relationshipType = DS.RelationshipChange.determineRelationshipType( | |
record.constructor, relationship); | |
if (relationshipType === 'manyToNone' || relationshipType === 'manyToMany' || relationshipType === 'manyToOne') { | |
json[json_key] = Ember.get(record, key).mapBy('id'); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment