Created
July 21, 2014 22:03
-
-
Save mrinterweb/18a94671a6def4cb7d79 to your computer and use it in GitHub Desktop.
Ember Data Serialize Attributes Example
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
# 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