Skip to content

Commit

Permalink
Preserve mutation changes when updating parent_id
Browse files Browse the repository at this point in the history
  • Loading branch information
schovi committed May 18, 2017
1 parent c27057c commit d20e0c3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/closure_tree/hierarchy_maintenance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,20 @@ def _ct_after_save
rebuild!
end
if public_send(changes_method)[_ct.parent_column_name] && !@was_new_record
tmp_previous_mutation_tracker = @previous_mutation_tracker
tmp_mutation_tracker = @mutation_tracker
tmp_mutations_from_database = @mutations_from_database
tmp_mutations_before_last_save = @mutations_before_last_save

# Resetting the ancestral collections addresses
# https://github.com/mceachen/closure_tree/issues/68
ancestor_hierarchies.reload
self_and_ancestors.reload

@previous_mutation_tracker = tmp_previous_mutation_tracker
@mutation_tracker = tmp_mutation_tracker
@mutations_from_database = tmp_mutations_from_database
@mutations_before_last_save = tmp_mutations_before_last_save
end
@was_new_record = false # we aren't new anymore.
@_ct_skip_sort_order_maintenance = false # only skip once.
Expand Down

0 comments on commit d20e0c3

Please sign in to comment.