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.
5201e306c37562746a8cdeebe24bef32?d=identicon&s=25 Jose Hales-Garcia (jose)
on 2006-02-25 17: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
3a83969376c805ef5b6042191fdb0ff3?d=identicon&s=25 Andreas S. (andreas)
on 2006-02-25 18: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.
5201e306c37562746a8cdeebe24bef32?d=identicon&s=25 Jose Hales-Garcia (Guest)
on 2006-02-25 21: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
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2006-02-25 23:14
(Received via mailing list)
On 2/25/06, Jose Hales-Garcia <jose@stat.ucla.edu> 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 Olson
http://techno-weenie.net
This topic is locked and can not be replied to.