Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create item at position 0 #297

Closed
Artur-Sulej opened this issue Jan 17, 2018 · 6 comments
Closed

Cannot create item at position 0 #297

Artur-Sulej opened this issue Jan 17, 2018 · 6 comments

Comments

@Artur-Sulej
Copy link

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
Copy link
Owner

brendon commented Jan 17, 2018

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.

@brendon brendon closed this as completed Jan 17, 2018
@Artur-Sulej
Copy link
Author

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 brendon reopened this Jan 17, 2018
@brendon
Copy link
Owner

brendon commented Jan 17, 2018

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
Copy link
Owner

brendon commented Mar 19, 2018

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

@Spone
Copy link

Spone commented Aug 11, 2018

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
Copy link
Owner

brendon commented Aug 12, 2018

I'm going to close this due to inactivity.

@brendon brendon closed this as completed Aug 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants