Skip to content

Commit

Permalink
Merge pull request ManageIQ#20642 from d-m-u/improving_genealogy_pare…
Browse files Browse the repository at this point in the history
…nt_setter

add ancestry case to the genealogy parent setter
  • Loading branch information
kbrock authored Nov 5, 2020
2 parents c39efe0 + 528509b commit dd2b056
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,19 @@ def genealogy_parent
end

def genealogy_parent=(parent)
@genealogy_parent_object = parent
with_relationship_type('genealogy') do
if use_ancestry?
self.parent = parent
else
@genealogy_parent_object = parent
end
end
end

# save_genealogy_information is only necessary for relationships using genealogy
# when using ancestry, the relationship will be saved after the fact
# when not using ancestry, the relationship is saved on assignment, necessitating the prior save of the vm/template record
# this variable is used to delay that assignment
def save_genealogy_information
if defined?(@genealogy_parent_object) && @genealogy_parent_object
with_relationship_type('genealogy') { self.parent = @genealogy_parent_object }
Expand Down

0 comments on commit dd2b056

Please sign in to comment.