May 23 2006
Representation d’elements, Element est défini comme ‘act_as_tree’
Dans un controller (element_controller.rb):
def showtreelist(item)
@tree+=""
if item.children.empty?
#action
else
for child in item.children
@tree+="- #{child.name}
"
showtreelist(child)
end
end
@tree+="
"
end
def showtree
@root=Element.find(0)
@tree=@root.name.to_s
showtreelist(@root)
end
Dans la vue de l’action showtree (showtree.rhtml):
<%= @tree %>
comments : 0 Add comment
