From a962e2d94ecbd652eeb3e77101b2a602defc8bfd Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Mon, 18 Mar 2024 20:04:53 +0100 Subject: [PATCH] fix(champ): fill stable_id and stream when cloning from old champs --- app/models/champ.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/champ.rb b/app/models/champ.rb index f9a28afe9..75790497f 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -226,6 +226,10 @@ class Champ < ApplicationRecord relationships = fork || !private? ? [:etablissement, :geo_areas] : [] deep_clone(only: champ_attributes + value_attributes, include: relationships, validate: !fork) do |original, kopy| + if original.is_a?(Champ) + kopy.write_attribute(:stable_id, original.stable_id) + kopy.write_attribute(:stream, 'main') + end ClonePiecesJustificativesService.clone_attachments(original, kopy) end end