Doug J. wrote:
ï¿½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’ve never heard of Pro-Active Record, and it sounds very much like it
is steering you wrong.
I take it that awesome_nested_set is not the same thing as
They are different plugins. When I did my research a few months ago,
awesome_nested_set seemed the better choice.
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
Yes, the classic adjacency list structure.
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.
You would need to make a very small change (add two numeric fields and
run one or two simple statements in the migration). It’s quite easy.
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.
Then learn about nested sets. The principle is not difficult, and the
data structure works much better. Joe Celko’s articles are a good place
in all and despite your undoubtedly good advice to the contrary, I
would like to proceed with a acts_as_tree solution.
It’s your decision, but be aware that based on what you’ve posted,
you’re basing your decision on the wrong criteria.
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.
It doesn’t work like that here. It’s more like trying to walk from New
York to Boston because learning to drive a car seems too hard.
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.
You’re most welcome. Again, please choose a data structure that
actually suits your needs, not one that looks simpler but won’t do the