Skip to content

Instantly share code, notes, and snippets.

@mrinterweb
Created July 21, 2014 22:03
Show Gist options
  • Save mrinterweb/18a94671a6def4cb7d79 to your computer and use it in GitHub Desktop.
Save mrinterweb/18a94671a6def4cb7d79 to your computer and use it in GitHub Desktop.
Ember Data Serialize Attributes Example
# This is a demonstration of how to have the attribute friend_ids serialized
# when posted to the server
# Add friends like this in the controller:
# group = @get('model')
# friend = @store.getById('friend', friend.get('id'))
# group.get('friends').addObject(friend)
# group.save()
App.Group = DS.Model.extend
friends: DS.hasMany 'friend', async: true
App.GroupSerializer = DS.ActiveModelSerializer.extend DS.EmbeddedRecordsMixin,
attrs:
friends:
serialize: 'ids'
deserialize: 'ids'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment