-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
Bug when use #insert_at on an invalid ActiveRecord object #99
Comments
I agree with this; reordering a list doesn't seem to be a good time to be validating the associated model. +1 |
|
Fixed with 7390b48 |
@mergulhao @knowuh FYI |
@swanandp awesome! thanks! |
@swanandp I appreciate that you fixed it. I just don't think that the right way is to use the I think that the "desirable" is that to run or not callbacks should be consistent. The way it's implemented when we run What do you think? Reference: |
Hi,
I found something that seems to be a bug.
If I have an invalid ActiveRecord object (
record.valid? => false
) and callsrecord.insert_at(new_position)
, it updates all other records using#shuffle_positions_on_intermediate_items
. But to save the current record it uses#set_list_position
method that calls#save!
on the record. Causing the save to abort since the record is invalid and leaving the database corrupted with a dup position.To me seems
#set_list_position
should not call#save!
. It should just save the record ignoring if it's invalid as already happens on#shuffle_positions_on_intermediate_items
that uses#update_all
method that ignore ActiveRecord validation.The new implementation should be something like:
I can PR with a fix if you think is useful.
The text was updated successfully, but these errors were encountered: