Skip to content

Instantly share code, notes, and snippets.

@zacheryph
Last active December 11, 2015 16:38
Show Gist options
  • Save zacheryph/4628629 to your computer and use it in GitHub Desktop.
Save zacheryph/4628629 to your computer and use it in GitHub Desktop.
collecting render calls from helper method
def account_tree(root, partial, output="")
sorter = ->(n) {[n.content.index_path, n.content.number]}
output += render(partial: partial, object: root.content) if root.content
root.children.sort_by(&sorter).each {|node| output = account_tree(node, partial, output)}
output.html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment