From 4da13f5dc2d2c37b6d5ba85d9b1316dd853fa87e Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Mon, 15 Apr 2024 13:15:18 +0200 Subject: [PATCH] fix(repetition): don't fail when trying to add a row of repetition without champ Cf procedure#31063 which have stable_id#1078289 without children --- app/controllers/champs/repetition_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/champs/repetition_controller.rb b/app/controllers/champs/repetition_controller.rb index 27e65b117..998dc00cb 100644 --- a/app/controllers/champs/repetition_controller.rb +++ b/app/controllers/champs/repetition_controller.rb @@ -6,7 +6,7 @@ class Champs::RepetitionController < ApplicationController row = @champ.add_row(@champ.dossier.revision) @first_champ_id = row.map(&:focusable_input_id).compact.first @row_id = row.first&.row_id - @row_number = @champ.row_ids.find_index(@row_id) + 1 + @row_number = @row_id.nil? ? 0 : @champ.row_ids.find_index(@row_id) + 1 end def remove