Commit 185e9e33 authored by Enrique García Cota's avatar Enrique García Cota

modifications on awesome_nested_set according to this post:…

modifications on awesome_nested_set according to this post: https://www.chiliproject.org/boards/2/topics/314
parent 86751132
......@@ -165,7 +165,7 @@ module CollectiveIdea #:nodoc:
# Rebuilds the left & rights if unset or invalid. Also very useful for converting from acts_as_tree.
def rebuild!
# Don't rebuild a valid tree.
return true if valid?
# return true if valid?
scope = lambda{|node|}
if acts_as_nested_set_options[:scope]
......@@ -181,7 +181,7 @@ module CollectiveIdea #:nodoc:
# set left
node[left_column_name] = indices[scope.call(node)] += 1
# find
find(:all, :conditions => ["#{quoted_parent_column_name} = ? #{scope.call(node)}", node], :order => "#{quoted_left_column_name}, #{quoted_right_column_name}, #{acts_as_nested_set_options[:order]}").each{|n| set_left_and_rights.call(n) }
find(:all, :conditions => ["#{quoted_parent_column_name} = ? #{scope.call(node)}", node], :order => "#{acts_as_nested_set_options[:order]}").each{|n| set_left_and_rights.call(n) }
# set right
node[right_column_name] = indices[scope.call(node)] += 1
node.save!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment