brendon / acts_as_list

An ActiveRecord plugin for managing lists.
http://brendon.github.io/acts_as_list/
MIT License
2.04k stars 355 forks source link

Reorder on delete? #380

Closed oyeanuj closed 4 years ago

oyeanuj commented 4 years ago

Hey @brendon, back again with a reorder related question! I'm not sure if we have already discussed this in another conversation in this repo but I couldn't find any documentation on what to expect when we delete an item. Can the other items automatically reorder?

Case: Item A at Position 1 Item B at Position 2

If I delete Item A, it seems like Item B is not updating to position 1. Then when I add Item C, it automatically gives it position 1 rather than after Item B.

Are both these behaviors to be expected?

brendon commented 4 years ago

Hi @oyeanuj, I hope all is well :D

acts_as_list should renumber the positions if you delete an item. It should also add an item to the end of the list. My guess is that there's an error with your scoping? What's your config?

oyeanuj commented 4 years ago

Ah, I think you are right about the scope issue. That might be it, thank you!

brendon commented 4 years ago

No worries :D