Always increase rank for tips correctly
This commit is contained in:
@ -267,10 +267,11 @@ class ExercisesController < ApplicationController
|
|||||||
rank += 1
|
rank += 1
|
||||||
unless current_exercise_tip.save
|
unless current_exercise_tip.save
|
||||||
flash[:danger] = current_exercise_tip.errors.full_messages.join('. ')
|
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
|
end
|
||||||
|
|
||||||
children = update_exercise_tips exercise_tip[:children], current_exercise_tip.id, rank
|
children = update_exercise_tips exercise_tip[:children], current_exercise_tip.id, rank
|
||||||
|
rank += children.length
|
||||||
|
|
||||||
result << current_exercise_tip.id
|
result << current_exercise_tip.id
|
||||||
result += children
|
result += children
|
||||||
|
Reference in New Issue
Block a user