Skip to content

Commit eea1a31

Browse files
committed
push
1 parent a7850a4 commit eea1a31

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/mongoid_acts_as_tree.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,20 @@ def acts_as_tree(options = {})
5353
# overwrite parent=
5454
def parent_with_checking=(new_parent)
5555
if new_parent.present?
56+
# chain to original relation
57+
parent_without_checking=(new_parent)
5658
if new_parent != self.parent && new_parent.is_a?(Mongoid::Acts::Tree)
5759
self.write_attribute parent_id_field, new_parent.id
5860
new_parent.children.push self, false
5961
end
6062
else
63+
# chain to original relation
64+
parent_without_checking=(nil)
6165
self.write_attribute parent_id_field, nil
6266
self.path = []
6367
self.depth = 0
6468
end
65-
66-
# chain to original relation
67-
parent_without_checking=(new_parent)
69+
6870
end
6971

7072
# use advise-around pattern to intercept mongoid relation

0 commit comments

Comments
 (0)