Forum: Ruby on Rails Enumerating over a Tree by Depth

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jose H. (Guest)
on 2006-02-25 18:05
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
Andreas S. (Guest)
on 2006-02-25 19:23
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.
Jose Hales-Garcia (Guest)
on 2006-02-25 22:46
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
Rick O. (Guest)
on 2006-02-26 00:14
(Received via mailing list)
On 2/25/06, Jose Hales-Garcia <removed_email_address@domain.invalid> 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-a...

--
Rick O.
http://techno-weenie.net
This topic is locked and can not be replied to.