fix create_new_revision
This commit is contained in:
parent
cb4c35e797
commit
4ec5b418cb
1 changed files with 12 additions and 1 deletions
|
@ -713,9 +713,20 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
|
||||
def create_new_revision
|
||||
draft_revision
|
||||
new_draft = draft_revision
|
||||
.deep_clone(include: [:revision_types_de_champ])
|
||||
.tap(&:save!)
|
||||
|
||||
children = new_draft.revision_types_de_champ.where.not(parent_id: nil)
|
||||
children.each do |child|
|
||||
old_parent = draft_revision.revision_types_de_champ.find(child.parent_id)
|
||||
new_parent = new_draft.revision_types_de_champ.find_by(type_de_champ_id: old_parent.type_de_champ_id)
|
||||
child.update!(parent_id: new_parent.id)
|
||||
end
|
||||
|
||||
new_draft.revision_types_de_champ.reload
|
||||
|
||||
new_draft
|
||||
end
|
||||
|
||||
def average_dossier_weight
|
||||
|
|
Loading…
Add table
Reference in a new issue