Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hyoshida/b82dfcf433b49700075c to your computer and use it in GitHub Desktop.
Save hyoshida/b82dfcf433b49700075c to your computer and use it in GitHub Desktop.
Display the category tree by awesome_nested_set
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