-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Saving with EmbeddedRecordsMixin does not update related models dirty attributes #2487
Comments
this similar? |
@jcope2013 Yeah it's similar and I read that before I posted, but that seems generally to be concerned about the dirtiness of the parent when related models change. Though I note the later comments on savesRelationship/savesModel do cover this scenario a lot better emberjs/rfcs#21 (comment) |
I ran into this issue, here's my story: http://stackoverflow.com/questions/28408274/how-to-update-child-records-in-the-store-when-parent-record-is-saved The demo in top post broke due to some So, are there any updates on this one? Also, is the manual method of updating child records kindly provided by @DEfusion an optimal one? It is so low-level that i'm kinda worried to use it. Is there a less hacky way? |
I've resolved the issue for me and published the solution as an Ember CLI addon: https://github.com/lolmaus/ember-cli-stained-by-children If it helps you, please star it. PS This issue should not be considered resolved until it works out of the box. |
I encounter this issue too. My usecase:
|
Please send a PR containing a failing test case for this issue. It will be much easier to fix. |
Agree, it would be good. Any pointers/hints on how to start? (I've never worked with the ember data tests) Is it a regular ember-cli project? |
Hi guys, is there any progress? |
Please re-open (as a new issue if necessary), hopefully with a failing test case or JSBin. I suspect this has been fixed since 1.13. Sorry but we're triaging inactive issues. Re-opening lets us see if people are still running into them more easily. |
I created a demo (http://jsbin.com/zejala/6/edit?js,output) simulating saving
hasMany
related models viaDS.EmbeddedRecordsMixin
and Rails'accepts_nested_attributes_for
.No matter what way the serializer is configured in Ember dirty attributes of the relationships records are not updated with those from the response, non dirty attributes are updated though.
The only workaround I have found is to manually go through and mark them individually as
willCommit
and thendidCommit
by overridingsave
on the model - I tried doing this in the serializer for better encapsulation but couldn't get it to work.If I've specified
serialize: 'records'
for my serializer when usingEmbeddedRecordsMixin
I would expect those records to be automatically set as saving/saved etc. along with the parent according to the normal save flow.The text was updated successfully, but these errors were encountered: