Nested BelongsTo relationships without a clear inverse


#1

I am new to ember.js and working on an app to do my wife’s Christmas list. I have created a Rails API which is up and running and can connect to the app properly. The API has a Friend resource, which will include her Friends, and they are linked together in a many-to-many relationship that has a specific association for each friend (termed ‘left’ and ‘right’) the idea being that some relationships like a marriage is asymmetric in that there is usually a wife and a husband - as opposed to other relationships like friends or cousins where both individuals have the same title. So the Relationships resource returns an object with two belongs_to relationships for the different friends called left and right, whereas the Friend resource returns an object with a hasMany association that’s just called relationships and includes all the relationships the Friend has regardless of being ‘left’ or ‘right’.

So, the problem is that I don’t know how to set up ember to cope with this scenario, since it wants an inverse to be specified between friends/relationships and relationship/left_friend_id or relationship/right_friend_id but clearly this isn’t possible.

Even after reading the documentation I don’t really know where to get started. Should I modify the REST adapter, or should I modify the route? Is there a way of making this work straight out of the box? Should I refactor the API to use JsonAPI and use the JsonAPI adapter? I appreciate this is probably a bit of a corner case, but I’m sure someone else must have come across this issue before!