Re: acts_as_tree

djolley
Fri, 07 Aug 2009 15:34:09 -0000

>  Have you read about the nested-set data structure?

Yes; but, not in detail.  The section on nested sets immediately
follows the section on acts_as_tree in "Pro-Active Record".

I take it that awesome_nested_set is not the same thing as
acts_as_nested_set?

In any event, here''s the deal.  I just stumbled onto acts_as_tree a
few days ago.  Before that, I was oblivious to it.  Because I was off
in oblivion, I hardcoded a solution for creating the hierarchical
view.  (It took me about 2 weeks! :) )  It uses a linked-records
approach where each record has a pointer to its ancestor much like
acts_as_tree.  Surprisingly, it seems to work just fine; however, the
code is about 100 lines in length and its messy.  I''m sure that my
code is even less efficient than act_as_tree; and, as I say, it seems
to work just fine.  So, I don''t think that performance is going to be
an issue.  I''d like to clean up my messy code.  I think that if I use
acts_as_tree, I can use my existing database.  I just have to be sure
to declare my foreign key since I named my pointer column
''parent''
rather than the default, ''parent_id''.  If I use a nested-set
approach,
I would have to modify/re-create the database.  In addition, based on
Ilan''s comments, I have a vague idea of how to proceed with
acts_as_tree where I am much more in the dark with nested sets.  All
in all and despite your undoubtedly good advice to the contrary, I
would like to proceed with a acts_as_tree solution.  That  doesn''t
mean that I won''t re-do it with nested sets at some future date.  I
just want to make sure that I can walk before I try flying.  I hope
that you guys will stick with me through my adventure which I''m not
even going to be able to begin for a couple of days because of other
things which have arisen.

Thanks ever so much for your awesome help.

            ... doug