Enumerating over a Tree by Depth

I have a model using acts_as_tree which is working fine.

Being new to Ruby I’m don’t know what enumerator is best to use for
traversing a tree by depth. I can write one, but before I do I wanted
to know if there is there an enumerator for traversing trees available
that the community recommends?

Thank you,
Jose

Jose Hales-Garcia wrote:

I have a model using acts_as_tree which is working fine.

Being new to Ruby I’m don’t know what enumerator is best to use for
traversing a tree by depth. I can write one, but before I do I wanted
to know if there is there an enumerator for traversing trees available
that the community recommends?

I don’t know if it contains an enumerator, but acts_as_nested_set is
more efficient than acts_as_tree if you need to do this kind of
iteration more often.

Andreas S. wrote:

I don’t know if it contains an enumerator, but acts_as_nested_set is
more efficient than acts_as_tree if you need to do this kind of
iteration more often.

It looks as if acts_as_nested_set is exactly what I am looking for.
Thank you for the suggestion.

Jose

On 2/25/06, Jose Hales-Garcia [email protected] wrote:

Andreas S. wrote:

I don’t know if it contains an enumerator, but acts_as_nested_set is
more efficient than acts_as_tree if you need to do this kind of
iteration more often.

It looks as if acts_as_nested_set is exactly what I am looking for.
Thank you for the suggestion.

You can also try the acts_as_threaded plugin:

http://www.railtie.net/articles/2006/02/05/rails-acts_as_threaded-plugin


Rick O.
http://techno-weenie.net