Creating a new record and adding a new embedded record will result in two requests (embedded: 'always'):
The second request is not necessary, because the child is embedded in the first request.
Creating a new embedded record on an existing parent results in a POST request to the childs url. My understanding is that it should perform a PUT request to the parents' url with the child embedded.
Added failing tests for saving embedded records.
Merge remote-tracking branch 'upstream/master' into embedded-saving-f…
I can confirm this exact problem.
@NilsLattek have you found a workaround?
Not yet. It might be possible to solve this using the new dirtyRecordsForHasManyChange methods. I am guessing that there is still some work going on for embedded records.
I have the exact same problem.
It seems to me that dirtyRecordsForHasManyChange can't solve the problem.
The problem is that the new embedded object is already in dirty state right after its creation with createRecord().
I can't find a way to remove it from its dirty state.
There is also a question on SO:
@bobey I think a newly created record (embedded or not) should be in a dirty state. I think the real problem here is that persistence is handled by separately for each record, instead of through the parent.
In both cases, persistence is handled through the parent.
That said, I don't know exactly how to fix this, my understanding of the inner workings of ember data isn't deep enough.
@sandstrom I just tested this one and it fixes the bug: https://github.com/emberjs/data/pull/629/files
worked for me : https://github.com/emberjs/data/pull/629/files
The first problem was fixed in: 3b91851
Seems to be fixed.