Skip to content

Instantly share code, notes, and snippets.

@radar
Forked from anonymous/gist:3722468
Created September 14, 2012 15:03
Show Gist options
  • Select an option

  • Save radar/3722480 to your computer and use it in GitHub Desktop.

Select an option

Save radar/3722480 to your computer and use it in GitHub Desktop.
module CommentsHelper
def putstree(text,hash,depth,trusted)
hash.each_pair do |k,v|
text << (render :partial => "shared/comment", :locals => {:trusted => trusted, :comment => k, :depth => depth})
if v != {}
putstree(text,v,depth+1,trusted)
end
end
if depth == 0
text
end
end
end
<% comments.each do |rootnode| %>
<% subtree = rootnode.subtree.arrange
depth = 0 %>
<%= putstree("",subtree,0,(current_user != nil and current_user.trustedFor(parent))).html_safe %>
<% end #end loop %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment