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

acts_as_list not updating position when scoped field is indexed #351

Closed map7 closed 3 months ago

map7 commented 5 years ago

I have a client which has many addresses and each address I use acts_as_list scoped by the client. My client_id in the addresses table has an index attached to it which broke my tests.

acts_as_list scope: :client

Now when I add the first address it gets position 1, and the second gets position 1. If I remove the index on client_id, then it works as expected. The first address gets position 1, and the second address I add to the client gets position 2. The only thing I changed was removing the index on client_id.

brendon commented 5 years ago

That's a strange one. I can't see how the index would be interacting with it. It's best to explicitly scope on the column name, so :client_id. Can you try that and let me know?

map7 commented 5 years ago

Same problem if I use client_id

brendon commented 5 years ago

Thanks for reporting back. Probably the next thing to look at doing is creating a failing test in our test suite. Do you think you'll be able to do that for me so we can investigate further? I assume you're just creating a standard index using rails migrations?

brendon commented 3 months ago

Closing due to lack of contact.