Closed yfxie closed 5 months ago
Hi @yfxie, this one runs deep! :) It's been around for a while. I don't have time to dig too deep at the moment but if you're able to figure out why we're doing this in the first place that'd help heaps! If we can remove this, or replace it with something that achieves the same outcome (without the bug) then that would be great.
Here's what I know:
reload
has been there as long as I've been maintaining this gem. For a while it was replaced by lock!
but this was causing problems so it was reverted. https://github.com/brendon/acts_as_list/commit/d0b2b815782374bb77b77b98dee7258c9adae589reload
was added https://github.com/brendon/acts_as_list/commit/8bc26426d3104876191fc579cc4fced21ee9e2bbThere are no issue references there that I could find, but it seems that we need to reload the position of items just before delete if we're deleting lots of them as their position will have changed and is used in shuffling things around.
If I'm free, I will try to figure out whether we can replace it. Thanks for your detailed explanation.
Closing this due to inactivity. Check out https://github.com/brendon/positioning as an alternative gem that doesn't exhibit this issue.
If we remove counter_cache and the test will pass. I found the bug due to
before_destroy :reload
(here)So the following code is a failure case too
For any reason, I think it shouldn't call reload at callbacks.