Closed egeriis closed 9 years ago
@egeriis thanks very much for opening all these issues.
Could you provide the code you're using to save the surveys
? That way we can try to replicate the problem.
In my save action I am simply calling save
on the model from my controller; this.get('model').save()
.
The options are added through this action:
addOption: function() {
var opts = this.get('model').get('options');
opts.pushObject(this.store.createRecord('option', {}));
}
The title
attribute are then bound in my template.
Is this sufficient?
After investigating a bit, I can see that this occurs because it is new option
instances that are not saved before the survey
model. But I can also see from jsonapi.org that this should not necessarily be possible.
@egerlis did you ever find a solution to this?
@kurko what are your thoughts about removing all hasMany attributes from createRecord
? How would you even refer to an uncreated hasMany attribute? They do not have IDs yet... hence the nulls. I don't see how the current state of JSONAPI can accommodate this scenario without two transactions...
@achan I believe what I ended up doing, was to save all options and wait for their promises to resolve before saving the parent model. I would prefer that ember-json-api
could handle this automatically, though.
Yeah. Currently, the best strategy is to save one then the other. However, that's kinda bad: what if the second fails and then the first shouldn't be saved? You can't really do a unique transaction for both.
I am closing this issue due to lack of activity and the impending deprecation in favour of the official Ember Data adapter. If you think this is an issue that relates to Ember Data please report the issue there.
When I save a new model to be persisted on the server, the payload for relationships appears to be wrong. In this example
options
is ahasMany
relationship:Model for
option
looks like this: