Refactor DossiersController#update

Nested ifs are heavier but easier to understand
as related conditions are visually grouped
This commit is contained in:
gregoirenovel 2018-09-06 13:31:29 +02:00
parent 230bf22b77
commit 6fe1f912c8

View file

@ -141,14 +141,16 @@ module NewUser
if errors.present? if errors.present?
flash.now.alert = errors flash.now.alert = errors
render :modifier render :modifier
elsif current_user.owns?(dossier)
if Flipflop.new_dossier_details?
redirect_to demande_dossier_path(@dossier)
else
redirect_to users_dossier_recapitulatif_path(@dossier)
end
else else
redirect_to users_dossiers_invite_path(@dossier.invite_for_user(current_user)) if current_user.owns?(dossier)
if Flipflop.new_dossier_details?
redirect_to demande_dossier_path(@dossier)
else
redirect_to users_dossier_recapitulatif_path(@dossier)
end
else
redirect_to users_dossiers_invite_path(@dossier.invite_for_user(current_user))
end
end end
end end