Merge pull request #4337 from aignatov-bio/ai-sci-7080-fix-step-element-deletetion

Fix step element delete callback [SCI-7080]
This commit is contained in:
aignatov-bio 2022-08-10 11:03:17 +02:00 committed by GitHub
commit 6334b481ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,7 +23,10 @@ class StepOrderableElement < ApplicationRecord
def decrement_following_elements_positions
step.with_lock do
yield
step.step_orderable_elements.where('position > ?', position).find_each do |step_orderable_element|
step.step_orderable_elements
.where('position > ?', position)
.order(position: :asc).each do |step_orderable_element|
# find_each ignore any ordering
step_orderable_element.position -= 1
step_orderable_element.save!
end