Hello: Does anyone have a solution to convert an acts_as_tree model to json that includes all its nodes? I trued using :include=>:children, but that only goes down to one single level. Any idea how to iterate the whole tree?
A:
You could write your own method that returns all descendants, however this is one of those cases where the type of tree that you are using is going to be pretty inefficient.
If you are worried about performance and database hits, you should look into one of the nested set gems, or the ancestry gem which are much more efficient ways to fetch tree branches.
jdl
2010-04-21 03:37:50