Skip to content

Instantly share code, notes, and snippets.

Created July 9, 2014 20:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Serialized hasMany
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