There is a model for group (that hasMany friend), and a model for friend (that hasMany group). When I try to save the model for a group, after adding a friend, this friend is now associated to the group but the group is not associated to the friend.
(All code is in CoffeeScript)
The models for group and friend are:
App.Group = DS.Model.extend name: DS.attr 'string' friends: DS.hasMany 'friend', async: true App.Friend = DS.Model.extend name: DS.attr 'string' groups: DS.hasMany 'group', async: true
And the acting handler for adding a friend to a group (in the group controller) is:
addFriend: (friend)-> friend = @store.getById('friend', friend.get('id')) group = @get('model') friends = group.get('friends') friends.addObject(friend) friend.get('groups').then (groups)=> groups.addObject(group) group.save()
Note that if a debug point is placed after the line “group.save()”, friend.get(‘groups’) returns the group that the friend is supposed to now be associated with. However, upon adding the same friend to another group, another single group (the one that was added) is in friend.get(‘groups’).