Closed 7vs closed 5 years ago
Hi @7vs, looks like you have a uniqueness constraint? Take a look at the sequential_updates
feature that will shuffle things around atomically so that you don't end up setting two positions the same while the shuffle happens.
Hi @brendon, thanks for your reply, I've seen thesequential _updates
features now and I've removed the uniqueness constraint, delegating that work to the gem:
validates_uniqueness_of :position, scope: :menu_id
Thank you.
Hi @7vs, you should be able to keep the uniqueness constraint (on the database if you want) and it should all still work. That's what it was designed for :)
I've removed the uniqueness constraint
@7vs Oops, this is a bad idea. Constraints should be enforced on the database level. sequential_updates
will work constraints.
@7vs Oops, this is a bad idea.
Yes, @swanandp I figured it out after testing it properly. I managed to return back my constraint so everything is working smoothly now. Thank you both :)
Hi, I have an issue with acts_as_list in a simple has_many relationship. When I try to update the position of items using the provided method I get an error: 'position taken', but if I run it again, I've got what was expected. Any thoughts?
here is the update action: