Fix step element delete callback [SCI-7080]

This commit is contained in:
Anton 2022-08-10 10:50:18 +02:00
parent 897a8f71ec
commit 5cd887831c

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