Merge pull request #10145 from tchak/fix-clone-with-stable-id
fix(champ): fill stable_id and stream when cloning from old champs
This commit is contained in:
commit
33125c691e
1 changed files with 4 additions and 0 deletions
|
@ -226,6 +226,10 @@ class Champ < ApplicationRecord
|
||||||
relationships = fork || !private? ? [:etablissement, :geo_areas] : []
|
relationships = fork || !private? ? [:etablissement, :geo_areas] : []
|
||||||
|
|
||||||
deep_clone(only: champ_attributes + value_attributes, include: relationships, validate: !fork) do |original, kopy|
|
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)
|
ClonePiecesJustificativesService.clone_attachments(original, kopy)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue