Re: acts_as_tree

djolley
Thu, 06 Aug 2009 15:59:03 -0000

> use siblings() to iterate through the node''s children and put a
for
> each, if the child itself has children then wash and repeat.. think
> helper functions and recursion..

Thanks to both contributors for the input.

This is not a homework assignment.  It represents an actual need; but,
I would like to treat it as a learning experience.  The tree involved
is going to be pretty small, I''m guessing typically 10 - 20 nodes.  I
think my best approach would be to begin with acts_as_tree; and, when,
as, and if I ever get that working then try advancing to a nested set
approach.  (Pro Active Record says that nested sets can be "a little
complex to grasp and manage".  That scares me at my level of
understanding.)

Having said that, please allow me to clarify the suggested
acts_as_tree approach.

> use siblings() to iterate through the node''s children

By "the nodes children" I think that you mean the children of each of
the root nodes.  Am I correct?

> put a for each child, if the child itself has children then wash
and repeat

Translation: For each child of a given root node:
if that child has no children put an for
that child.
Else put a and begin processing the
grandchildren

I think that I get the concept.  I''m going to give it a whirl.  I will
likely have additional questions.  However, it could be days before I
discover them. :)

             ... doug