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

Cannot create item at position 0 #297

Closed Artur-Sulej closed 6 years ago

Artur-Sulej commented 6 years ago

Current setting: acts_as_list scope: :parent_id, top_of_list: 0 Creating record with position: 0 places it at the other end of collection, e.g. having 5 records (positions 0..4) it's placed at position 5 instead of 0. Using acts_as_list scope: :record_id, top_of_list: 0, add_new_at: :top makes it possible to place records at position 0.

brendon commented 6 years ago

That's not a bug, that's by design. The first settings tells acts_as_list to use 0 based indexing instead of the traditional 1 based indexing. The second settings tells acts_as_list to add new items to the top of the list rather than the bottom.

Artur-Sulej commented 6 years ago

But is it forbidden to place the item at the position 0 (with the first setting)? The consequence of this design is that item that was created first stays forever at position 0. This is because no newly created item can take its place. In my opinion only passing no position should make use of the add_new_at option.

brendon commented 6 years ago

Would you be able to fork and create a failing test in our test suite for this issue? That'll help us get a better idea of what the problem is and then work toward a solution :)

brendon commented 6 years ago

@hot-cheese could you follow this up with a failing test?

Spone commented 6 years ago

I'm having the same issue apparently. top_of_list: 0 doesn't seem to be taken into account at all.

When seeding data, I have exactly the same positions, whether I add top_of_list: 0 or not.

EDIT: nevermind, I had a scoping issue.

brendon commented 6 years ago

I'm going to close this due to inactivity.