I have a model App.Leg that has many App.LegPlayers:
App.Leg = DS.Model.extend({
match: DS.belongsTo('App.Match'),
legPlayers: DS.hasMany('App.LegPlayer'),
winner: DS.belongsTo('App.Player')
});
App.LegPlayer = DS.Model.extend({
leg: DS.belongsTo('App.Leg'),
player: DS.belongsTo('App.Player'),
turns: DS.hasMany('App.Turn')
});
I can persist them in an embedded way (using only 1 POST request) with the following mapping:
App.Adapter.map('App.Leg', {
legPlayers: {embedded: 'always'}
});
But loading a record from Rails (active_models_serializers) only works using the following mapping (or no mapping at all):
App.Adapter.map('App.Leg', {
leg_players: {embedded: 'always'}
});
But not when I use the underscored version, or no mapping, Ember wants to persist the legPlayers in separate POST requests.
So my question is: how can I get ember to both loaded the legplayers as part of the leg, and get the legplayers to be POSTed to the server as part of the leg. So without using separate requests. It's seems that right now, I can only get one scenario working at a time: POSTing works with only using 'legPlayers', loading works only using 'leg_players'.