From 53eb3e6ad094ed1eebd86ec412c118df7aba8300 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 15 Nov 2022 14:31:29 +0100 Subject: [PATCH] chore(dossier): cleanup champs nested attributes --- app/controllers/users/dossiers_controller.rb | 12 +----------- app/models/champs/repetition_champ.rb | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 5dc1517bb..3703fcdb2 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -394,11 +394,6 @@ module Users champs_public_attributes: [ :id, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :departement, :code_departement, value: [], champs_attributes: [:id, :_destroy, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :departement, :code_departement, value: []] - ], - # FIXME: remove after migration - champs_attributes: [ - :id, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :departement, :code_departement, value: [], - champs_attributes: [:id, :_destroy, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :departement, :code_departement, value: []] ] }) end @@ -457,12 +452,7 @@ module Users errors = [] if champs_params[:dossier] - # FIXME: remove after migration - dossier_params = champs_params[:dossier] - if dossier_params.key?(:champs_attributes) - dossier_params[:champs_public_attributes] = dossier_params.delete(:champs_attributes) - end - @dossier.assign_attributes(dossier_params) + @dossier.assign_attributes(champs_params[:dossier]) # FIXME: in some cases a removed repetition bloc row is submitted. # In this case it will be treated as a new record, and the action will fail. @dossier.champs_public.filter(&:block?).each do |champ| diff --git a/app/models/champs/repetition_champ.rb b/app/models/champs/repetition_champ.rb index 83d691ffc..112a8aa87 100644 --- a/app/models/champs/repetition_champ.rb +++ b/app/models/champs/repetition_champ.rb @@ -20,7 +20,7 @@ # type_de_champ_id :integer # class Champs::RepetitionChamp < Champ - accepts_nested_attributes_for :champs, allow_destroy: true + accepts_nested_attributes_for :champs delegate :libelle_for_export, to: :type_de_champ def rows