Permalink
Browse files

changed save to save!

  • Loading branch information...
1 parent ff2cca4 commit a7850a4a3cba5c13b312aa7681a617c2c0789ac3 @sled committed Jul 7, 2011
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/mongoid_acts_as_tree.rb
@@ -54,17 +54,17 @@ def acts_as_tree(options = {})
def parent_with_checking=(new_parent)
if new_parent.present?
if new_parent != self.parent && new_parent.is_a?(Mongoid::Acts::Tree)
- # chain to original relation
- parent_without_checking=(new_parent)
self.write_attribute parent_id_field, new_parent.id
new_parent.children.push self, false
end
- else
- parent_without_checking=(nil)
+ else
self.write_attribute parent_id_field, nil
self.path = []
self.depth = 0
end
+
+ # chain to original relation
+ parent_without_checking=(new_parent)
end
# use advise-around pattern to intercept mongoid relation
@@ -290,7 +290,7 @@ def <<(object, will_save=true)
c_desc.depth = c_desc.depth + delta_depth
c_desc.path = c_desc.path.slice(prev_depth, c_desc.path.length - prev_depth).unshift(*object.path)
# only will_save == false will block autosave
- c_desc.save if will_save != false && object.tree_autosave
+ c_desc.save! if will_save != false && object.tree_autosave
end
end
end

0 comments on commit a7850a4

Please sign in to comment.