Last active
December 11, 2015 16:38
-
-
Save zacheryph/4628629 to your computer and use it in GitHub Desktop.
collecting render calls from helper method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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