lib/nested_set/base.rb in nested_set-1.7.0 vs lib/nested_set/base.rb in nested_set-1.7.1
- old
+ new
@@ -101,10 +101,14 @@
}
scope :leaves, lambda {
where("#{quoted_right_column_name} - #{quoted_left_column_name} = 1").
order(quoted_left_column_name)
}
+ scope :nodes, lambda {
+ where("(#{quoted_right_column_name} - #{quoted_left_column_name} - 1) / 2 != 0").
+ order(quoted_left_column_name)
+ }
scope :with_depth, proc {|level| where(:"#{depth_column_name}" => level).order(quoted_left_column_name) }
define_callbacks :move, :terminator => "result == false"
end
end
@@ -280,10 +284,10 @@
hash
end
end
def nodes_for_rebuild(node, node_scope)
- where(parent_column_name => node).
+ where(parent_column_name => node.id).
where(node_scope).
order(order_for_rebuild).
all
end