On 19 aug, 19:35, Marnen Laibow-Koser <mar...@marnen.org> wrote: > On Aug 19, 1:10 pm, jhaagmans <jaap.haagm...@gmail.com> wrote: > > > Thank you Marnen, I've made it work using acts_as_tree, which can do > > everything I was looking for in combination with acts_as_list. > > NO. STOP. BAD IDEA. > > Now that I've got your attention, please take a moment and read over > this thread, particularly the part where I explained that nested sets > can do what acts_as_tree cannot: get all descendants (no matter how > deep) with a single database query. There is no way to do that at all > with acts_as_tree.
Now look at the example I gave here earlier in this thread. I've used it and it generates exactly as many queries as my acts_as_tree (which is based on his example). Not one less. So, what's that guy doing wrong? I can't figure it out and yes, I've looked into the rdoc. > > > I'm > > unsure as to what the advantages of using acts_as_nested_set over > > acts_as_tree are. > > Your database access will be *much* more efficient. There is no > reason to even consider acts_as_tree for most projects, because it is > so inefficient. I know it *looks* simpler than awesome_nested_set, > but beyond the simplest queries, it's inefficient and needlessly > complex. Okay, but again: why? The same story as the previous one? If I can do all this with one query, I would like to know how. And I would like to know how I can get the sortable functionality to work with acts_as_nested_set. You said I should use acts_as_list, but doesn't that make the lft and rgt columns obsolete? And then again, what's the advantage of using acts_as_nested_set? > > I highly recommend reading some articles (such as those by Joe Celko) > on the nested-set structure. It's not all that difficult to > understand, and it has many advantages over the adjacency list that > acts_as_tree provides. > > There's an introductory article by Joe Celko > athttp://www.intelligententerprise.com/001020/celko.jhtml?_requestid=12... > (don't worry about the long SQL procedures at the end), and Vadim > Tropashko's comparison of SQL tree structures > athttp://www.dbazine.com/oracle/or-articles/tropashko4may also be worth > reading. Executive summary: don't use an adjacency list for anything > nontrivial. I'll look into it, but chances are I'm not getting this to work with the scarce information available on the net. And I really have to move on, I have so many other things to do before my next deadline. > > > In fact, my controller and my views are a lot easier > > to understand and just as powerful. > > No. awesome_nested_set should not make your controller or views any > harder to understand. If anything, it should make them *easier* to > understand, because you do not have to do lots of database queries to > retrieve the records you need. Then I've caught a bad example. The problem is: it's the -only- real example I could find! And I really need examples to figure these kinds of things out! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---