Closed Gee-Bee closed 1 year ago
Hi @Gee-Bee, I see what you mean. Would you be interested in creating a PR to fix this? I'll take a look too but am pretty short on time lately. If you have any ideas please let me know :)
Actually, I think I see a hopefully easy solution to the problem. I'll keep you posted.
Try https://github.com/brendon/acts_as_list/tree/avoid_collision to see if that helps. I've added tests that confirm it works.
Actually, since the tests are green I've merged it with master
. Give master
a go and see how you get on :)
Wow, that was fast. Tried master
branch. It's working like a gold.
You managed to resolve the issue and clean up the code along the way.
Big props for your work.
Thanks @Gee-Bee! :) I'll spin a new release.
According to 0.8.0 Upgrade Notes:
This works as expected, repositioning other items' positions if position is taken.
In my use case:
add_new_at: nil
(because position is optional),If user specify position that is already taken, DB is left in inconsistent state (or uniqueness constraint violation error is raised).
Expected result: reordering other items, like in
add_new_at: :top
scenario.As a workaround I included the following concern in my class:
This workaround seems like a "bad example" from the
1) Use the Most Concise API
in README:but at least it works. The "Good example" generates possible duplicates when
add_new_at: :top
is not given.