Find All Children With Acts_as_tree
Join the DZone community and get the full member experience.Join For Free
#Find all children including grandchildren and children of their descendants recursively #Using acts_as_tree #inside example model Category
def all_children all =  self.children.each do |category| all << category root_children = category.all_children.flatten all << root_children unless root_children.empty? end return all.flatten end
Opinions expressed by DZone contributors are their own.