Hello all, I need a good technique to create a tree menu based off pages in a database with RoR. So, pages would look something like this in the db: pages ( id parent_id title content ) Obviously, the parent_id would be 0 or null for the top-level pages and any sub-pages would have the id under parent_id. What I''m looking for as far as a read-out is a simple unordered-list with sub-lists under the parent''s list item.. so: <ul> <li>Parent <ul> <li>Child 1</li> <li>Child 2</li> </ul> </li> </ul> If I can have it be recursive that would also be great. Thanks --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Have a look into acts_as_tree. On Jan 18, 2008 2:40 PM, zscott <zachary.s.scott-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello all, > I need a good technique to create a tree menu based off pages in a > database with RoR. So, pages would look something like this in the db: > > pages ( > id > parent_id > title > content > ) > > Obviously, the parent_id would be 0 or null for the top-level pages > and any sub-pages would have the id under parent_id. What I''m looking > for as far as a read-out is a simple unordered-list with sub-lists > under the parent''s list item.. so: > > <ul> > <li>Parent > <ul> > <li>Child 1</li> > <li>Child 2</li> > </ul> > </li> > </ul> > > If I can have it be recursive that would also be great. > > Thanks > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Have a look here http://www.vaporbase.com/postings/A_Micro-CMS_in_Rails linoj On Jan 17, 11:10 pm, zscott <zachary.s.sc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello all, > I need a good technique to create a tree menu based off pages in a > database with RoR. So, pages would look something like this in the db: > > pages ( > id > parent_id > title > content > ) > > Obviously, the parent_id would be 0 or null for the top-level pages > and any sub-pages would have the id under parent_id. What I''m looking > for as far as a read-out is a simple unordered-list with sub-lists > under the parent''s list item.. so: > > <ul> > <li>Parent > <ul> > <li>Child 1</li> > <li>Child 2</li> > </ul> > </li> > </ul> > > If I can have it be recursive that would also be great. > > Thanks--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---