私の見解では、私はすべてのページを取得します
私はすべてのページとすべての子供とサブ子供を取得します。以下に示すようなツリー構造を取得する方法:
<% for page in @pages%>
<li id="<%= page.id%>_page">
<div class="link">
#my attributes for the div<
/div>
#here I got the all siblings of that page. But here the structure is of just two
#levels. I need upto n-levels.
<% @childs = page.*descendants* %>
<% if !@childs.nil? && !@childs.empty? %>
<% for child in @childs%>
<ol class="child">
<li id="<%= child.id%>_page">
<div class="link">
#my attributes for the div
</div>
</li>
</ol>
<%end%>
<%end%>
</li>
<%end%>
ネストされたセットを使用していて、次のような構造が必要です。
page1
page 2
page 3
page 3.1
page 3.2
page3.4
...so on to last child
page 4
page 5
....so on to N-levels...