diff --git a/lib/mongoid_acts_as_tree.rb b/lib/mongoid_acts_as_tree.rb index 4b2ace6..bc75a02 100644 --- a/lib/mongoid_acts_as_tree.rb +++ b/lib/mongoid_acts_as_tree.rb @@ -131,7 +131,11 @@ def children=(new_children_list) alias replace children= def descendants - return [] if new_record? + # workorund for mongoid unexpected behavior + _new_record_var = self.instance_variable_get(:@new_record) + _new_record = _new_record_var != false + + return [] if _new_record self.class.all_in(path_field => [self._id]).order_by tree_order end