Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ancestry case to the genealogy parent setter #20642

Merged
merged 1 commit into from
Nov 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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