Created
March 9, 2015 05:53
-
-
Save hyoshida/b82dfcf433b49700075c to your computer and use it in GitHub Desktop.
Display the category tree by awesome_nested_set
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
Category.roots.map do |root| | |
tree = [] | |
root.class.each_with_level(root.self_and_descendants) do |category, level| | |
tree << "#{' ' * level}#{category.name}" | |
end | |
tree | |
end.join("\n").display |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment