-
Notifications
You must be signed in to change notification settings - Fork 463
Suckerfish
Nikos Timiopulos edited this page Jul 25, 2014
·
4 revisions
want a suckerfish dropdown?
def suckerfish(node)
fuc = lambda do |nodes|
return "" if nodes.empty?
return "<ul>" +
nodes.inject("") do |string, (node, children)|
string + "<li rel='#{node.id}'>" +
link_to(node.name, node.path) +
fuc.call(children) +
"</li>"
end +
"</ul>"
end
fuc.call(node.descendants.arrange)
end
For Rails 3 & 4, if you want to use this method in views as a helper_method :suckerfish
add view_context
before link_to
:
view_context.link_to(node.name, node.path) + # don't forget to set your path