Adds an option to force nested set rebuild (#9577).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7815 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-11-15 19:58:43 +00:00
parent 594074d91b
commit 36728d779d
1 changed files with 3 additions and 2 deletions

View File

@ -162,9 +162,10 @@ module CollectiveIdea #:nodoc:
end
# Rebuilds the left & rights if unset or invalid. Also very useful for converting from acts_as_tree.
def rebuild!
def rebuild!(force=false)
# Don't rebuild a valid tree.
return true if valid?
# valid? doesn't strictly validate the tree
return true if !force && valid?
scope = lambda{|node|}
if acts_as_nested_set_options[:scope]