collectiveidea/awesome_nested_set

Feature: self_and_children

map7 opened this issue · 2 comments

map7 commented

I've got a need to list the parent and it's children and was thinking that there should be a self_and_children feature.

@map7 This feature exists as self_and_descendants, which will return a flat collection of the parent and all of its nested children. You can find the method in question here:

# Returns a collection including itself and all of its nested children
def self_and_descendants
# using _left_ for both sides here lets us benefit from an index on that column if one exists
nested_set_scope.right_of(left).left_of(right)
end

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.