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

Show items with same position in higher and lower items #231

Closed jpalumickas closed 8 years ago

jpalumickas commented 8 years ago

Currently, when we're trying to move up and down items with same positions, they are not found in scope, because they have the same id. We need to show all items with the same id but exclude current one.

@brendon can you take a look ?

brendon commented 8 years ago

Thanks @jpalumickas. A great fix! I thought of another potential problem that probably needs its own PR. What if we have 1, 2, [2], 2, 3, 4 and we pick out the one in brackets and move the rest lower. We'll end up with 1, 2, 3, 3, 4, 5. Ideally we'd want 1, 2, 3, 4, 5, 6.

I suppose that's a harder problem to fix though. Unless we renumber all of the lower items explicitly instead of relying on their current position with SQL. Maybe something like this: http://stackoverflow.com/questions/15930514/mysql-auto-increment-temporary-column-in-select-statement