diff --git a/backend/app/controllers/spree/admin/resource_controller.rb b/backend/app/controllers/spree/admin/resource_controller.rb index 1a298f6c5a3..9e5d704d864 100644 --- a/backend/app/controllers/spree/admin/resource_controller.rb +++ b/backend/app/controllers/spree/admin/resource_controller.rb @@ -78,8 +78,11 @@ def create def update_positions ActiveRecord::Base.transaction do - params[:positions].each do |id, index| - model_class.find_by(id: id)&.set_list_position(index) + positions = params[:positions] + records = model_class.where(id: positions.keys).to_a + + positions.each do |id, index| + records.find { |r| r.id == id.to_i }&.set_list_position(index) end end