I have an array of @pages below
#<Page id: 1, url: "/location1", name: "Information", sort_order: 2, parent_id: nil>
#<Page id: 2, url: "/location2", name: "Information 2", sort_order: 2, parent_id: 4>
#<Page id: 3, url: "/location3", name: "Information 3", sort_order: 1, parent_id: >
#<Page id: 4, url: "/location4", name: "Information 4", sort_order: 1, parent_id: nil>
#<Page id: 5, url: "/location5", name: "Information 5", sort_order: 1, parent_id: 2>
#<Page id: 6, url: "/location6", name: "Information 6", sort_order: 3, parent_id: nil>
And i am trying to build a nav with these pages...Note this is just an example I really have 70 pages similar to this
I want the final outcome to look like this
<ul>
<li><a href="/location4">Information 4</a>
<ul>
<li><a href="/location3">Information 3</a></li>
<li><a href="/location2">Information 2</a>
<ul><li><a href="/location5">Information 5</a></li></ul>
</li>
</ul>
</li>
<li><a href="/location1">Information 1</a></li>
<li><a href="/location6">Information 6</a></li>
</ul>
So the parent_id will signal if the li has another child ul and li and the sort order is the ordering of the chil li's
I cant seem to wrap my brain around how i need to loop over @pages efficiently ...any ideas..