Forum: Ruby on Rails basic tree questions

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.
Tarscher (Guest)
on 2007-01-24 17:44
(Received via mailing list)
Hi all,

I have  2 very basic questions:
* I have tree structures in my table and currently use
Node.find_all_by_parent_id(nil). but this returns all the trees with
parent_id == nil. Since I have more than 1 tree structure I want
something like Node.find_all_by_id(id) . Is this function available?

* Is there a function available that deletes an entire branch?

The answers are probably easily available in the mannuals but I haven't
found them. Maybe someone can point me out where they get this info
from.

Thanks in advance
Stijn
Jean-Christophe M. (Guest)
on 2007-01-24 20:22
(Received via mailing list)
Hi,

Le 24 janv. 07, à 16:43, Tarscher a écrit :
> * I have tree structures in my table and currently use
> Node.find_all_by_parent_id(nil). but this returns all the trees with
> parent_id == nil. Since I have more than 1 tree structure I want
> something like Node.find_all_by_id(id) . Is this function available?

Maybe use :scope to differentiate your trees.

> * Is there a function available that deletes an entire branch?

In Nested Sets, yes. With acts_as_tree I'm afraid you'll have to
recurse.

Jean-Christophe M.
--
symetrie.com

Better Nested Set for rails:
http://opensource.symetrie.com/trac/better_nested_set
This topic is locked and can not be replied to.