Always increase rank for tips correctly

This commit is contained in:
Sebastian Serth
2020-10-14 13:09:36 +02:00
parent bfcb536cc9
commit 2d8a18169e

View File

@ -267,10 +267,11 @@ class ExercisesController < ApplicationController
rank += 1
unless current_exercise_tip.save
flash[:danger] = current_exercise_tip.errors.full_messages.join('. ')
redirect_to(edit_exercise_path(@exercise)) and return
redirect_to(edit_exercise_path(@exercise)) and break
end
children = update_exercise_tips exercise_tip[:children], current_exercise_tip.id, rank
rank += children.length
result << current_exercise_tip.id
result += children