The controller:
def tree
@items = Media.find_by_parent_id(nil).children
end
The View:
<h2 class="title">Choose an Item:</h1>
<%= render_partial "item", [@items, 0] %>
The Partial:
<% for item in items[0] %>
<div id="m<%= $m %>"
class="gallery-menu-normal" itemType="<%=
item.media_type %>" itemId="<%= item.id
%>"><span></span><%= item.name
%></div>
<% if item.has_children? %>
<div id="s<%= $m %>"
class="gallery-submenu">
<% $m=$m+1 %>
<%= render_partial "item", [item.children, items[0]] %>
</div>
<% else %>
<% $m=$m+1 %>
<% end %>
<% end %>
I using this model but I don''t know why this , 0] in [@items, 0]
And why this items[0] and not @items ... etc..
What is wrong??
--
Pedro C. Valentini
pedro-p14LI7ZcAE/pVLaUnt/cCQC/G2K4zDHf@public.gmane.org
+55 (21) 8708-8035