I am trying to figure out a graceful way to "draw" out an arbitrary tree structure, defined using acts_as_tree. My ultimate goal is to convert the parent/child relationships into a nested hash that can be converted into a Yaml file.
example tree:
root
--child
--child
----subchild
----subchild
------anotherchld
--child
--child
----subchild
------anotherhchild
--child
I would like it to produce this:
{'root' =>
[{'child' => nil },
{'child' =>
[{'subchild' => nil },
{'subchild' => nil }]},
...
]}
Perhaps this is not the best approach? Can you provide me an alternate approach for converting the tree so it is more or less like the text above, but as Yaml?