Andy wrote:> Josh Susser wrote:
>> This is a great place to use acts_as_nested_set, which lets you fetch
an
>> item and all its subtree contents in one query. Once fetched, you can
>> walk the tree in Ruby as you please.
>
> I have found the method of all_children of acts_as_nested_set can get
> all the nested children of the root,but i want to display the tree
> structure in the page. Therefore direct_children has to be used:
>
> root.direct_children.each do|subtype|
> subtype.direct_children.each do|thirdtype|
> .....
> end
> end
>
> This is the same as the original..
Once you have the items fetched into memory as model objects, you can
fake up the hierarchy by indenting based on the depth in the tree. Bob
Silva has a nice writeup on how to do it:
http://www.railtie.net/articles/2006/03/31/implement-acts_as_threaded-without-a-plugin
--
Josh Susser
http://blog.hasmanythrough.com
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---