Stop crashing when removed repetition row is submitted

This commit is contained in:
Paul Chavard 2021-01-26 16:50:32 +01:00
parent 6a5722a5e5
commit 1b5aef10f2

View file

@ -346,6 +346,11 @@ module Users
if champs_params[:dossier]
@dossier.assign_attributes(champs_params[:dossier])
# FIXME in some cases a removed repetition bloc row is submitted.
# In this case it will be trated as a new records and action will fail.
@dossier.champs.filter(&:repetition?).each do |champ|
champ.champs = champ.champs.filter(&:persisted?)
end
if @dossier.champs.any?(&:changed?)
@dossier.last_champ_updated_at = Time.zone.now
end