I’d like some pointers on how to display nested items in their
hierarchy. I’m developing a project that uses habtm (as opposed to “acts
as tree”). I can interact with the elements using “parent”, “child” etc.
fine. I just can’t figure out how to make the elements display in
For example, if Ruby on Rails is a child of Server-Side and a sibling to
PHP, and Server-side is a child of Coding and a sibling to Application,
and Coding is a child of Main, how do I get the contents of the database
to display in a browser something like:
Ruby on Rails
If I sort the database by parent_id, I get stuff grouped by parent_id,
not organized in the hierarchy. In some other scripting environment I
would probably write some recursive routine but don’t know how to
approach it with Rails.
Any tips or pointers would be appreciated. Even what terms to use in
google - I’m getting bird-related sites when I search for “nested”!