Data: Record not shown after transition in a relationship many to many

Created on 21 Nov 2016  路  3Comments  路  Source: emberjs/data

Hi, I have a relationship many to many with the models user, address with an intermediate model (user-to-address). When a user wants to delete an address, I store the records address and user-to-address in a service, remove user-to-address record from the relationship and set them as deleted with deleteRecord, allowing the user to undo the action and recover them.

To undo the action, I get those records from the service, rollback their attributes with rollBackAttributes and add them to the user using pushObject on the relationship.

If I delete an address and press the undo button it works perfectly, the address disappears and reappears again. But, if I delete an address, go back to the previous route, enter again on User 1 and press the undo button, the address isn't shown.

I've tested that the same implementation works with a 1 to many relationship. Here's an ember-twiddle that reflects this behaviour.

tl;dr
in ember-twiddle:

  1. click on users link
  2. click on User 1 link
  3. click on the x button next to Street 1
  4. click on back button
  5. click again on User 1 link
  6. click on undo button

Omitting steps 4 and 5 the example works as expected.

Most helpful comment

DEBUG: -------------------------------
DEBUG: Ember      : 3.0.0
DEBUG: Ember Data : 3.0.2

@runspired I've created a new project with the above versions and now it works :smile: Sorry for keeping the issue opened so long but I'm glad to see that the problem has been fixed. Thanks for your effort guys! :heart:

All 3 comments

I spent some time trying to debug this today. I didn't come to anything conclusive but I noticed that calling flushCanonical on the relationships updates the value so it will render correctly. I'm out of time for now but hopefully this bit of info might help someone else looking at this issue.

@HenryVonfire is this still an issue on latest master?

DEBUG: -------------------------------
DEBUG: Ember      : 3.0.0
DEBUG: Ember Data : 3.0.2

@runspired I've created a new project with the above versions and now it works :smile: Sorry for keeping the issue opened so long but I'm glad to see that the problem has been fixed. Thanks for your effort guys! :heart:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

buschtoens picture buschtoens  路  4Comments

xomaczar picture xomaczar  路  3Comments

jherdman picture jherdman  路  4Comments

stefanpenner picture stefanpenner  路  4Comments

concertiv picture concertiv  路  4Comments