From dontfall at gmail.com Mon Jan 1 18:44:52 2007 From: dontfall at gmail.com (Krishna Dole) Date: Mon, 1 Jan 2007 18:44:52 -0500 Subject: [Betternestedset-talk] Mailing list question In-Reply-To: <20070101224507.85300.qmail@web54007.mail.yahoo.com> References: <20070101224507.85300.qmail@web54007.mail.yahoo.com> Message-ID: <8d64b97d0701011544t49a7d50eu2217c4572e88069b@mail.gmail.com> Hi Drew, > No it looks like my messages aren't getting through. I'm receiving messages > from the list, but obviously mine aren't getting through. To what address > should I be sending messages? I've been using betternestedset-talk at rubyforge.org. > Anyway I'll endeavour to re-send my messages. In the meantime you may like > to see this Rail wiki page I put together. I quoted you (after asking on > the mailing list and not getting a response): > > http://wiki.rubyonrails.org/rails/pages/BetterNestedSet I had noticed the wiki page-- thanks for putting that up. Let us know if the problems with the list continue. By the way, is there anyone else out there who has unsuccessfully tried sending messages to the list? If so, please send me or JCM a direct email so we can look into it. > Thanks for your work on this plugin. It's great stuff. You're welcome! Cheers, Krishna From dontfall at gmail.com Tue Jan 2 12:34:03 2007 From: dontfall at gmail.com (Krishna Dole) Date: Tue, 2 Jan 2007 12:34:03 -0500 Subject: [Betternestedset-talk] Exciting(?) changes to BetterNestedSet In-Reply-To: References: <8d64b97d0612291212u40bd20a5t4d66d00a98b9a1a7@mail.gmail.com> Message-ID: <8d64b97d0701020934s10c245c4i13808c3321360e60@mail.gmail.com> Hi Jean-Christophe, > I'd like to see benchmarks though, since using associations could be > slower, don't you think ? I'm pretty sure it is slower, but only (I think) on update. Benchmarking is on my to-do list, once I get the callback problem and some other things sorted out. Krishna From dontfall at gmail.com Tue Jan 2 12:47:56 2007 From: dontfall at gmail.com (Krishna Dole) Date: Tue, 2 Jan 2007 12:47:56 -0500 Subject: [Betternestedset-talk] A couple of questions In-Reply-To: References: <8d64b97d0612271533k13336ba3u6c1e449966f5ada5@mail.gmail.com> <8d64b97d0612281146i300d326di97a7d1028ac476d3@mail.gmail.com> Message-ID: <8d64b97d0701020947h783aac29n33cd6559e08cd7af@mail.gmail.com> > Is there a simple way to achieve this ? like testing :scope ? > or an option :inherit_scope_on_creation to explicitely ask to copy > scope from parent on creation ? I'm not sure what the best solution is. I've opened a ticket for it: http://opensource.symetrie.com/trac/better_nested_set/ticket/25 From qaexls at gmail.com Tue Jan 2 21:36:18 2007 From: qaexls at gmail.com (Ho-Sheng Hsiao) Date: Tue, 2 Jan 2007 20:36:18 -0600 Subject: [Betternestedset-talk] Unit tests Message-ID: <625688fb0701021836x447d58caqaf0445971bf45ca6@mail.gmail.com> Hi, I just recently discovered better_nested_sets and I would like to use it in my app. However, when I installed it from svn, both the trunk and the ez-set failed unit tests. Do the current HEAD revision pass the test / if not, what is a good revision number to use? If it does succeed, I'd like to know as I want to make sure there isn't a bug in my environment first before I use it in my app. For context purposes: the use in my app is very simple. A nested set to store a navigation menu. Few inserts, lots of reads, relatively trivial amount of nodes (often no more than 20). I just want to make sure stuff works before I convert the existing data stored with acts_as_tree into this one. Hosh From dontfall at gmail.com Tue Jan 2 23:04:04 2007 From: dontfall at gmail.com (Krishna Dole) Date: Tue, 2 Jan 2007 23:04:04 -0500 Subject: [Betternestedset-talk] Unit tests In-Reply-To: <625688fb0701021836x447d58caqaf0445971bf45ca6@mail.gmail.com> References: <625688fb0701021836x447d58caqaf0445971bf45ca6@mail.gmail.com> Message-ID: <8d64b97d0701022004i62c03051o100e6812bbd4c511@mail.gmail.com> Hi Hosh, > I just recently discovered better_nested_sets and I would like to use > it in my app. However, when I installed it from svn, both the trunk > and the ez-set failed unit tests. Do the current HEAD revision pass > the test / if not, what is a good revision number to use? If it does > succeed, I'd like to know as I want to make sure there isn't a bug in > my environment first before I use it in my app. I just ran all the tests on both trunk (rev. 32) and ez-set without any failures (Rails 1.1.6, SQLite3, MySQL 5.0 and PgSQL 8.1). What rake command are you invoking the tests with, and what failures are you seeing? > > For context purposes: the use in my app is very simple. A nested set > to store a navigation menu. Few inserts, lots of reads, relatively > trivial amount of nodes (often no more than 20). I just want to make > sure stuff works before I convert the existing data stored with > acts_as_tree into this one. This sounds like a good scenario for using a nested set. I'm optimistic that better_nested_set will do what you need. Cheers, Krishna From dontfall at gmail.com Tue Jan 2 23:11:19 2007 From: dontfall at gmail.com (Krishna Dole) Date: Tue, 2 Jan 2007 23:11:19 -0500 Subject: [Betternestedset-talk] before_update problem In-Reply-To: <20061231141923.19650@gmx.net> References: <20061230233304.142010@gmx.net> <8d64b97d0612302051gcd776cfye0fdee32d8a37e35@mail.gmail.com> <20061231141923.19650@gmx.net> Message-ID: <8d64b97d0701022011x5466665chdb3a1366a6af417a@mail.gmail.com> Hi Matze, Happy New Years to you too! I've tracked down the source of the before_update problem. When I overrode #update to make the nested set concurrency-safe, it apparently broke the magical juju that triggers the callback. So I can have concurrency-safety or before_update, but not both :( Is there anyone on this list who knows enough about Rails core to suggest a way that we can do both? Cheers, Krishna From qaexls at gmail.com Tue Jan 2 23:11:46 2007 From: qaexls at gmail.com (Ho-Sheng Hsiao) Date: Tue, 2 Jan 2007 22:11:46 -0600 Subject: [Betternestedset-talk] Unit tests In-Reply-To: <8d64b97d0701022004i62c03051o100e6812bbd4c511@mail.gmail.com> References: <625688fb0701021836x447d58caqaf0445971bf45ca6@mail.gmail.com> <8d64b97d0701022004i62c03051o100e6812bbd4c511@mail.gmail.com> Message-ID: <625688fb0701022011j2ed1cc80va470a7ca00cf3124@mail.gmail.com> On 1/2/07, Krishna Dole wrote: > > I just recently discovered better_nested_sets and I would like to use > > it in my app. However, when I installed it from svn, both the trunk > > and the ez-set failed unit tests. Do the current HEAD revision pass > > the test / if not, what is a good revision number to use? If it does > > succeed, I'd like to know as I want to make sure there isn't a bug in > > my environment first before I use it in my app. > > I just ran all the tests on both trunk (rev. 32) and ez-set without > any failures (Rails 1.1.6, SQLite3, MySQL 5.0 and PgSQL 8.1). What > rake command are you invoking the tests with, and what failures are > you seeing? Ok, good. It is my setup then. It is probably due to Rails 1.2RC2. I'll try the unit test on a different machine and see if the tests passes. If it is due to 1.2 RC2 and you are interested, I'll post up the test results. -Hosh From qaexls at gmail.com Tue Jan 2 23:18:48 2007 From: qaexls at gmail.com (Ho-Sheng Hsiao) Date: Tue, 2 Jan 2007 22:18:48 -0600 Subject: [Betternestedset-talk] Unit tests In-Reply-To: <625688fb0701022011j2ed1cc80va470a7ca00cf3124@mail.gmail.com> References: <625688fb0701021836x447d58caqaf0445971bf45ca6@mail.gmail.com> <8d64b97d0701022004i62c03051o100e6812bbd4c511@mail.gmail.com> <625688fb0701022011j2ed1cc80va470a7ca00cf3124@mail.gmail.com> Message-ID: <625688fb0701022018r794ba35ep90b9a2f7dc7ffbf2@mail.gmail.com> Krishna, It is indeed 1.2RC2 causing the problem. Fortunately, this app won't need 1.2 features. -Hosh From dontfall at gmail.com Wed Jan 3 09:15:32 2007 From: dontfall at gmail.com (Krishna Dole) Date: Wed, 3 Jan 2007 09:15:32 -0500 Subject: [Betternestedset-talk] Unit tests In-Reply-To: <625688fb0701022018r794ba35ep90b9a2f7dc7ffbf2@mail.gmail.com> References: <625688fb0701021836x447d58caqaf0445971bf45ca6@mail.gmail.com> <8d64b97d0701022004i62c03051o100e6812bbd4c511@mail.gmail.com> <625688fb0701022011j2ed1cc80va470a7ca00cf3124@mail.gmail.com> <625688fb0701022018r794ba35ep90b9a2f7dc7ffbf2@mail.gmail.com> Message-ID: <8d64b97d0701030615r5f4e49d8mcd11b9401160fd6e@mail.gmail.com> Hi Hosh, Thanks for letting us know. Well, better nested set should worked with 1.2, so I'll look at it later today. Krishna On 1/2/07, Ho-Sheng Hsiao wrote: > Krishna, > > It is indeed 1.2RC2 causing the problem. Fortunately, this app won't > need 1.2 features. > > -Hosh > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > From linicks at gmail.com Wed Jan 3 09:42:20 2007 From: linicks at gmail.com (Nick Pavlica) Date: Wed, 3 Jan 2007 07:42:20 -0700 Subject: [Betternestedset-talk] Unit tests In-Reply-To: <8d64b97d0701030615r5f4e49d8mcd11b9401160fd6e@mail.gmail.com> References: <625688fb0701021836x447d58caqaf0445971bf45ca6@mail.gmail.com> <8d64b97d0701022004i62c03051o100e6812bbd4c511@mail.gmail.com> <625688fb0701022011j2ed1cc80va470a7ca00cf3124@mail.gmail.com> <625688fb0701022018r794ba35ep90b9a2f7dc7ffbf2@mail.gmail.com> <8d64b97d0701030615r5f4e49d8mcd11b9401160fd6e@mail.gmail.com> Message-ID: On 1/3/07, Krishna Dole wrote: > Hi Hosh, > Thanks for letting us know. Well, better nested set should worked > with 1.2, so I'll look at it later today. I'm developing against the current 1.2 branch and haven't noticed any issues. --Nick From linicks at gmail.com Wed Jan 3 09:47:23 2007 From: linicks at gmail.com (Nick Pavlica) Date: Wed, 3 Jan 2007 07:47:23 -0700 Subject: [Betternestedset-talk] A couple of questions In-Reply-To: <8d64b97d0612300840j45de37ffw363dd6062f2e5512@mail.gmail.com> References: <8d64b97d0612271533k13336ba3u6c1e449966f5ada5@mail.gmail.com> <8d64b97d0612281146i300d326di97a7d1028ac476d3@mail.gmail.com> <8d64b97d0612290705tedf4e9fy4682d48ebd920440@mail.gmail.com> <8d64b97d0612291022o251b56ben10493300a31cfbcd@mail.gmail.com> <8d64b97d0612300840j45de37ffw363dd6062f2e5512@mail.gmail.com> Message-ID: > Glad to hear things are working. > > > acts_as_nested_set :root_scope => :root_id > > The problem is that if you have multiple trees, each with multiple > roots, the code wouldn't know if a new record without a parent should > be saved with a scope that would make it part of an existing tree or > the root of a new tree. If we discarded the multiple root option, we > could make it work. > It sounds like that idea would be going in the wrong direction. :) > > I noticed your announcement regarding the changes to the plug-in. > > Would you recommend moving to the new branch, or hold off for now? > > If you have things working the way you want, there isn't really any > reason to switch. I'm very happy with the way things are working at this point. I have even noticed an improvement in performance with my test data after moving from acts_as_tree. Thanks! --Nick From dontfall at gmail.com Wed Jan 3 10:10:45 2007 From: dontfall at gmail.com (Krishna Dole) Date: Wed, 3 Jan 2007 10:10:45 -0500 Subject: [Betternestedset-talk] A couple of questions In-Reply-To: References: <8d64b97d0612281146i300d326di97a7d1028ac476d3@mail.gmail.com> <8d64b97d0612290705tedf4e9fy4682d48ebd920440@mail.gmail.com> <8d64b97d0612291022o251b56ben10493300a31cfbcd@mail.gmail.com> <8d64b97d0612300840j45de37ffw363dd6062f2e5512@mail.gmail.com> Message-ID: <8d64b97d0701030710j2a41afd4td1b7432cff1a6ea3@mail.gmail.com> Hi Nick, > > The problem is that if you have multiple trees, each with multiple > > roots, the code wouldn't know if a new record without a parent should > > be saved with a scope that would make it part of an existing tree or > > the root of a new tree. If we discarded the multiple root option, we > > could make it work. > > > It sounds like that idea would be going in the wrong direction. :) Just to clarify, I wasn't suggesting we discard the option of having multiple trees. Rather, we currently allow individual trees to have more than one root (these multiple roots are siblings). This is often confusing for people, but convenient in some situations. > I'm very happy with the way things are working at this point. I have > even noticed an improvement in performance with my test data after > moving from acts_as_tree. Hey, that's great. Krishna From jc.michel at symetrie.com Thu Jan 4 03:46:47 2007 From: jc.michel at symetrie.com (Jean-Christophe Michel) Date: Thu, 4 Jan 2007 09:46:47 +0100 Subject: [Betternestedset-talk] Fwd: [Rails] Re: How to hide a database column from ActiveRecord? Message-ID: Hi Krishna, D?but du message r?exp?di? : > David Scheffel wrote: >> Can I tell ActiveRecord to ignore this column and not to add it to the >> Attributes array? > > I submitted a patch at http://dev.rubyonrails.org/ticket/6896 which > adds an attr_readonly method to ActiveRecord::Base to ignore attributes > in update queries. It also fixes a bug with counter_cache. Hopefully > it receives enough support and provides enough value to be applied, but > if not I can make it into a plugin. Don't you think this would be the solution for lft and rgt and the concurrency pb ? Jean-Christophe Michel -- symetrie.com Better Nested Set for rails: http://opensource.symetrie.com/trac/better_nested_set From dontfall at gmail.com Thu Jan 4 10:47:55 2007 From: dontfall at gmail.com (Krishna Dole) Date: Thu, 4 Jan 2007 10:47:55 -0500 Subject: [Betternestedset-talk] Fwd: [Rails] Re: How to hide a database column from ActiveRecord? In-Reply-To: References: Message-ID: <8d64b97d0701040747y509b7270j5e2c8929cc4531e5@mail.gmail.com> Yes! I found that ticket just yesterday and added a comment in support of it, in fact. I guess we should send an email to the core list pleading for its inclusion. cheers, Krishna On 1/4/07, Jean-Christophe Michel wrote: > Hi Krishna, > > D?but du message r?exp?di? : > > David Scheffel wrote: > >> Can I tell ActiveRecord to ignore this column and not to add it to the > >> Attributes array? > > > > I submitted a patch at http://dev.rubyonrails.org/ticket/6896 which > > adds an attr_readonly method to ActiveRecord::Base to ignore attributes > > in update queries. It also fixes a bug with counter_cache. Hopefully > > it receives enough support and provides enough value to be applied, but > > if not I can make it into a plugin. > > Don't you think this would be the solution for lft and rgt and the > concurrency pb ? > > Jean-Christophe Michel > -- > symetrie.com > > Better Nested Set for rails: > http://opensource.symetrie.com/trac/better_nested_set > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > From info at loobmedia.com Thu Jan 4 15:31:31 2007 From: info at loobmedia.com (loobmedia - webdevelopment) Date: Thu, 4 Jan 2007 21:31:31 +0100 Subject: [Betternestedset-talk] with_scope integration Message-ID: <45D4F0AF-8E75-429E-8D81-DA367D534F0C@loobmedia.com> Hi all, I'm thinking about adding proper scoping for all (sub)node related queries using with_scope. That way one can easily do this for example: node.children(:conditions => ["type = ?", 'folder'], :order => 'nodes.name', :include => :metadata) It looks like this addition could be useful anywhere base_set_class.find is called, propably by having a new method find_node which will take care of wrapping the scope in with_scope. I'd like to contribute these additions (and tests). Any thoughts on this? Regards, Fabien Franzen From dontfall at gmail.com Thu Jan 4 16:52:52 2007 From: dontfall at gmail.com (Krishna Dole) Date: Thu, 4 Jan 2007 16:52:52 -0500 Subject: [Betternestedset-talk] with_scope integration In-Reply-To: <45D4F0AF-8E75-429E-8D81-DA367D534F0C@loobmedia.com> References: <45D4F0AF-8E75-429E-8D81-DA367D534F0C@loobmedia.com> Message-ID: <8d64b97d0701041352y5ca10ce4v39b063934cf6b5ef@mail.gmail.com> Hi Fabien, That sounds promising-- and if I understand correctly, would also (elegantly) close http://opensource.symetrie.com/trac/better_nested_set/ticket/18. I'm looking forward to seeing your changes. Be sure you grab the source from rubyforge (svn co svn://rubyforge.org/var/svn/betternestedset) instead of trac. Also, unfortunately testing is broken under Rails 1.2 rc1 (but if you see a way to fix it... :) cheers, Krishna On 1/4/07, loobmedia - webdevelopment wrote: > Hi all, > > I'm thinking about adding proper scoping for all (sub)node related > queries using with_scope. That way one can easily do this for example: > > node.children(:conditions => ["type = ?", 'folder'], :order => > 'nodes.name', :include => :metadata) > > It looks like this addition could be useful anywhere > base_set_class.find is called, propably by having a new method > find_node which will take care of wrapping the scope in with_scope. > > I'd like to contribute these additions (and tests). Any thoughts on > this? > > Regards, > > Fabien Franzen > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > From mark.noten at itfc.be Fri Jan 5 10:28:53 2007 From: mark.noten at itfc.be (Mark.noten) Date: Fri, 5 Jan 2007 16:28:53 +0100 Subject: [Betternestedset-talk] Output a tree in the view Message-ID: <79bb11acd1d26ce403549ee2fc828975@217.66.0.26> Hi all, as a newbie to ROR and user of better nested set, I'm wondering if someone has a code snippet to put me in the right way for displaying a partial tree of a node in the view. The problem is that I don't know how up front how many levels my tree will have. I'm thinking of the Composite pattern of the GoF for displaying the three. But how would you use that pattern with a clean model, view and controller separtion? Any suggestions are welcome! Best regards, Mark Noten ________________________________________________ Message sent using UebiMiau 2.7.10 From dontfall at gmail.com Fri Jan 5 11:10:48 2007 From: dontfall at gmail.com (Krishna Dole) Date: Fri, 5 Jan 2007 11:10:48 -0500 Subject: [Betternestedset-talk] Output a tree in the view In-Reply-To: <79bb11acd1d26ce403549ee2fc828975@217.66.0.26> References: <79bb11acd1d26ce403549ee2fc828975@217.66.0.26> Message-ID: <8d64b97d0701050810g430039f3nf891509dffae8f1b@mail.gmail.com> Hi Mark, I'm not sure exactly what you mean, but have you looked at the helper provided with the plugin? Krishna > as a newbie to ROR and user of better nested set, I'm wondering if someone > has a code snippet to put me in the right way for displaying a partial tree > of a node in the view. > > The problem is that I don't know how up front how many levels my tree will > have. I'm thinking of the Composite pattern of the GoF for displaying the > three. But how would you use that pattern with a clean model, view and > controller separtion? > > Any suggestions are welcome! > > Best regards, > > Mark Noten > > > ________________________________________________ > Message sent using UebiMiau 2.7.10 > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > From jc.michel at symetrie.com Fri Jan 5 11:57:05 2007 From: jc.michel at symetrie.com (Jean-Christophe Michel) Date: Fri, 5 Jan 2007 17:57:05 +0100 Subject: [Betternestedset-talk] Output a tree in the view In-Reply-To: <79bb11acd1d26ce403549ee2fc828975@217.66.0.26> References: <79bb11acd1d26ce403549ee2fc828975@217.66.0.26> Message-ID: <663e6151bb398a475b20924100d0cb58@symetrie.com> Hi Mark, Le 5 janv. 07, ? 16:28, Mark.noten a ?crit : > as a newbie to ROR and user of better nested set, I'm wondering if > someone > has a code snippet to put me in the right way for displaying a partial > tree > of a node in the view. You can use style="margin-left:<%= item.level %>em;" in your view to have items indented according to their level. Displaying vertical lines like in a mail thread is harder... Jean-Christophe Michel -- symetrie.com Better Nested Set for rails: http://opensource.symetrie.com/trac/better_nested_set From info at loobmedia.com Fri Jan 5 13:18:29 2007 From: info at loobmedia.com (loobmedia - webdevelopment) Date: Fri, 5 Jan 2007 19:18:29 +0100 Subject: [Betternestedset-talk] with_scope integration Message-ID: <200A3DD1-D338-45F5-A6C7-9C9098B82589@loobmedia.com> Hi Krishna, My changes (due for this weekend) will indeed fix that ticket. Yesterday I took a look at your ez-set implementation. I'm curious, where should I apply my changes? To the standard plugin or to the 'new' ez-set? Are there any drawbacks to the latter for example? Regards, Fabien From dontfall at gmail.com Fri Jan 5 13:39:05 2007 From: dontfall at gmail.com (Krishna Dole) Date: Fri, 5 Jan 2007 13:39:05 -0500 Subject: [Betternestedset-talk] with_scope integration In-Reply-To: <200A3DD1-D338-45F5-A6C7-9C9098B82589@loobmedia.com> References: <200A3DD1-D338-45F5-A6C7-9C9098B82589@loobmedia.com> Message-ID: <8d64b97d0701051039g633b4588j5b865e923bec284b@mail.gmail.com> Hi Fabien, So far as I know, the only drawbacks to 'ez-set' are that write performance is expected to be worse (though we haven't benchmarked that yet), and that it hasn't seen as much real-world testing. Go ahead and make your changes to trunk, and I will apply them to the branch. Thanks again for helping! Krishna On 1/5/07, loobmedia - webdevelopment wrote: > Hi Krishna, > > My changes (due for this weekend) will indeed fix that ticket. > Yesterday I took a look at your ez-set implementation. I'm curious, > where should I apply my changes? To the standard plugin or to the > 'new' ez-set? Are there any drawbacks to the latter for example? > > Regards, > > Fabien > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > From mark.noten at itfc.be Fri Jan 5 16:55:39 2007 From: mark.noten at itfc.be (Mark Noten) Date: Fri, 5 Jan 2007 22:55:39 +0100 Subject: [Betternestedset-talk] Output a tree in the view In-Reply-To: <8d64b97d0701050810g430039f3nf891509dffae8f1b@mail.gmail.com> Message-ID: <20070105215523.1FFFA4145@europa.telenet-ops.be> Hi all, Sorry about my brief explanation. I think a small example will quickly show what I'm trying to say. To model a sales organization, I'm using better nested set with a :scope on the column product_id that is a FK to a products table. There can be multiple roots that represent top level sales agents for a certain product and each node is ofcourse a sales agent. A sales agent can write multiple contracts and for each contract he gets a commission on the month he wrote it. A sales agent also gets commission from his children that wrote contracts. Enough said, the sales structure like the following A | \ \ B C D | | E F Could generate a monthly sales report for sales agent A like the following: == Own contracts == A Contract 1 Contract 2 == Contracts children == B Contract 3 == Contracts from children == E Contract 5 D Contract 4 For sales agent B the sales report of that month would just be just a part of the above report: == Own contracts == B Contract 3 == Contracts from children == E Contract 5 I would need a displaying algorithm that would work for any node of the tree and with a tree of unknown depth. I apologize if this mail has little or nothing to do with the better nested set talk. But I think that displaying a tree is as important than creating the tree itself. Thanks for your reply, Mark -----Original Message----- From: Krishna Dole [mailto:dontfall at gmail.com] Sent: vrijdag 5 januari 2007 17:11 To: Mark.noten; betternestedset-talk at rubyforge.org Subject: Re: [Betternestedset-talk] Output a tree in the view Hi Mark, I'm not sure exactly what you mean, but have you looked at the helper provided with the plugin? Krishna > as a newbie to ROR and user of better nested set, I'm wondering if someone > has a code snippet to put me in the right way for displaying a partial tree > of a node in the view. > > The problem is that I don't know how up front how many levels my tree will > have. I'm thinking of the Composite pattern of the GoF for displaying the > three. But how would you use that pattern with a clean model, view and > controller separtion? > > Any suggestions are welcome! > > Best regards, > > Mark Noten > > > ________________________________________________ > Message sent using UebiMiau 2.7.10 > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > From mhe_mailing at gmx.de Sat Jan 6 06:45:17 2007 From: mhe_mailing at gmx.de (Matthias Heigl) Date: Sat, 06 Jan 2007 12:45:17 +0100 Subject: [Betternestedset-talk] item.level store in db Message-ID: <20070106114517.111000@gmx.net> Hi List, how do you think about storing the level of an entry into the database. For each entry you request item.level there now is a count * request to the database. In a huge set this can be a performance issue. At most applications you have much more reading then writing to a database, so this can improve performance. For backward compatibility this could be added via an option like class MyModel < ActiveRecord::Base acts_as_nested_set :level => :depth end Something similar it's in acts_as_threaded or as a callback: def before_create # Update the child object with its parents attrs unless self[:parent_id].to_i.zero? self[:depth] = parent[:depth].to_i + 1 end end How do you think about this? Cheers, Matze From jc.michel at symetrie.com Sat Jan 6 09:01:37 2007 From: jc.michel at symetrie.com (Jean-Christophe Michel) Date: Sat, 6 Jan 2007 15:01:37 +0100 Subject: [Betternestedset-talk] Output a tree in the view In-Reply-To: <20070105215523.1FFFA4145@europa.telenet-ops.be> References: <20070105215523.1FFFA4145@europa.telenet-ops.be> Message-ID: <7d7813122e14fc3dc5c252967acaf6e7@symetrie.com> Hi, Le 5 janv. 07, ? 22:55, Mark Noten a ?crit : > Enough said, the sales structure like the following > > A > | \ \ > B C D > | | > E F > > Could generate a monthly sales report for sales agent A like the > following: > > == Own contracts == > A > Contract 1 > Contract 2 > > == Contracts children == > B > Contract 3 > == Contracts from children == > E > Contract 5 > D > Contract 4 > > For sales agent B the sales report of that month would just be just a > part > of the above report: > > == Own contracts == > B > Contract 3 > == Contracts from children == > E Contract 5 > > I would need a displaying algorithm that would work for any node of > the tree > and with a tree of unknown depth. Seems that you would need to render :partial => 'contract', and call the same render :partial from inside _contract.rhtml to render sub contracts. Jean-Christophe Michel -- symetrie.com Better Nested Set for rails: http://opensource.symetrie.com/trac/better_nested_set From jc.michel at symetrie.com Sat Jan 6 11:25:04 2007 From: jc.michel at symetrie.com (Jean-Christophe Michel) Date: Sat, 6 Jan 2007 17:25:04 +0100 Subject: [Betternestedset-talk] item.level store in db In-Reply-To: <20070106114517.111000@gmx.net> References: <20070106114517.111000@gmx.net> Message-ID: Hi Matthias, Le 6 janv. 07, ? 12:45, Matthias Heigl a ?crit : > how do you think about storing the level of an entry into the database. > > For each entry you request item.level there now is a count * request > to the database. In a huge set this can be a performance issue. > > At most applications you have much more reading then writing to a > database, so this can improve performance. > ... > How do you think about this? Are you sure it's not premature optimisation ? If you have benchmarks proving this is a weak point in betternestedset performances and your solution enhances them, I agree, go ahead. I would tend to think that db engine internal optimization can be quite as good as the one we can add in interpreted ruby layer... Jean-Christophe Michel -- symetrie.com Better Nested Set for rails: http://opensource.symetrie.com/trac/better_nested_set From tony.kruse at gmail.com Tue Jan 9 12:42:40 2007 From: tony.kruse at gmail.com (Tony K.) Date: Tue, 9 Jan 2007 12:42:40 -0500 Subject: [Betternestedset-talk] Reference to neighboring sibling Message-ID: <52fe24490701090942i378e3b82n45d450daf84cf618@mail.gmail.com> I would like to be able to move an entry among it's siblings on the same level. Is it possible to reference a neighbor sibling without knowing it's id, (i.e. next neighboring sibling right or left)? From dontfall at gmail.com Tue Jan 9 13:13:29 2007 From: dontfall at gmail.com (Krishna Dole) Date: Tue, 9 Jan 2007 13:13:29 -0500 Subject: [Betternestedset-talk] Reference to neighboring sibling In-Reply-To: <52fe24490701090942i378e3b82n45d450daf84cf618@mail.gmail.com> References: <52fe24490701090942i378e3b82n45d450daf84cf618@mail.gmail.com> Message-ID: <8d64b97d0701091013r58073517k3bc7cb41f8317d44@mail.gmail.com> Hi Tony, Fabien Franzen has just sent me a patch with that sort of functionality. I'll try to apply it soon, though I'm busy this week. In the meantime, you can fairly easily accomplish it with code like this (untested): sibs = node.siblings node.move_to_right_of(sibs[sibs.index_of(node)] + 1) (this code doesn't catch condition of node being last sibling) Krishna On 1/9/07, Tony K. wrote: > I would like to be able to move an entry among it's siblings on the > same level. Is it possible to reference a neighbor sibling without > knowing it's id, (i.e. next neighboring sibling right or left)? > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > From dontfall at gmail.com Tue Jan 9 20:02:39 2007 From: dontfall at gmail.com (Krishna Dole) Date: Tue, 9 Jan 2007 20:02:39 -0500 Subject: [Betternestedset-talk] Fabien Franzen's enhancements Message-ID: <8d64b97d0701091702t74637b52v2448f4ea1f8f2c5f@mail.gmail.com> Hi All, Yesterday Fabien sent me a bunch of enhancements, which I've attached to this message. I wanted to respond on the list, so others could voice their opinions. Fabien-- I've looked over your patch, and I'm quite impressed-- it looks like you have done excellent work on better_nested_set. My specific comments are as follows: The new find and count methods look great, and ought to be quite useful (e.g. trac ticket 18). The methods #recurse_result_set, #result_to_array and #result_to_xml all look fine to me, though I'm not the person to ask. JCM-- do you have input on these methods, based on your work with the helper? I like the new sibling query methods (#next_sibling and friends), but I'm wondering if we should use the same method names as acts_as_list, to maintain interchangeability. Should #move_to_top and #move_to_bottom use #swap? It seems that this will cause unexpected reordering. If we had nodes (a, b, c, d) and we called a.move_to_bottom, the order would be (d, b, c, a) instead of the expected (for me at least) (b, c, d, a). Which brings us to the #swap method itself-- all of the new sibling reordering methods could be accomplished with existing move_to methods, so I'm wondering how much of a need for #swap there is. (I recognize that #swap offers performance benefits if you do need to swap two distant nodes.) If we decide to keep it, I think the update statements for #swap and #move_to are equivalent, and could be handled by a single method. That's it for my comments-- what does everyone else on the list think? I really like these enhancements, and I am looking forward to seeing them committed. Krishna -------------- next part -------------- A non-text attachment was scrubbed... Name: betternestedset.zip Type: application/zip Size: 28196 bytes Desc: not available Url : http://rubyforge.org/pipermail/betternestedset-talk/attachments/20070109/20217abb/attachment-0001.zip From info at loobmedia.com Wed Jan 10 03:42:31 2007 From: info at loobmedia.com (loobmedia - webdevelopment) Date: Wed, 10 Jan 2007 09:42:31 +0100 Subject: [Betternestedset-talk] Fabien Franzen's enhancements Message-ID: <0B6DC2B1-1FD0-491F-8DBA-38796BBFBA6A@loobmedia.com> Hi, Thanks for the pointers, Krishna. I'm looking forward to the other's opinions as well. > The new find and count methods look great, and ought to be quite > useful (e.g. trac ticket 18). > > The methods #recurse_result_set, #result_to_array and #result_to_xml > all look fine to me, though I'm not the person to ask. JCM-- do you > have input on these methods, based on your work with the helper? I've implemented these methods as follows: - starting with the first node available, gather al of it's siblings - this way each level is established - in the final iteration, any stray nodes are gathered in case of disjointed result sets I've spent a great deal of time on this, looking for better ways to accomplish it, but sofar the solution above seems to work best. > > I like the new sibling query methods (#next_sibling and friends), but > I'm wondering if we should use the same method names as acts_as_list, > to maintain interchangeability. If all is well, I provided aliases wherever desired to keep interchangeability. Maybe we should just switch to the aliased names instead? > Should #move_to_top and #move_to_bottom use #swap? It seems that this > will cause unexpected reordering. If we had nodes (a, b, c, d) and we > called a.move_to_bottom, the order would be (d, b, c, a) instead of > the expected (for me at least) (b, c, d, a). I stand corrected at this one indeed. Good catch. I'll look into it. > Which brings us to the #swap method itself-- all of the new sibling > reordering methods could be accomplished with existing move_to > methods, so I'm wondering how much of a need for #swap there is. (I > recognize that #swap offers performance benefits if you do need to > swap two distant nodes.) If we decide to keep it, I think the update > statements for #swap and #move_to are equivalent, and could be handled > by a single method. Valid points as well. I do think #swap in itself is quite useful when moving two distant nodes, since you probably can't know when to use #move_to_left_of or #move_to_right_of in that case. AFAIK you would have to check the previous sibling and the next sibling also if the former is nil. I will change the sibling reordering implementation to move_to_methods. Expect a new patch soon! - Fabien -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20070110/aed0888e/attachment.html From dontfall at gmail.com Wed Jan 10 11:35:13 2007 From: dontfall at gmail.com (Krishna Dole) Date: Wed, 10 Jan 2007 11:35:13 -0500 Subject: [Betternestedset-talk] Fabien Franzen's enhancements In-Reply-To: References: <8d64b97d0701091648t7147fbbfyc18c7dd65c00e041@mail.gmail.com> Message-ID: <8d64b97d0701100835y1184751eg614721d635a714a5@mail.gmail.com> Hi Fabien, The new sibling reordering methods look good to me. I see your aliased method names for acts_as_list now-- for some reason I missed those. That looks great. As for whether we just use only the acts_as_list method names, I don't have a strong opinion either way. I'm fine with retaining the #swap method. I recently refactored move_to, so I think I could combine them. If you need #swap now go ahead and include it, otherwise I will work on combining it with move_to over the next few weeks. Cheers, Krishna On 1/10/07, Atelier Fabien - Fabien Franzen wrote: > Krishna, > > I've changed the sibling methods now.: > > # Moves a node one up amongst its siblings. Does nothing if it's already > # the first sibling. > def move_lower > next_sib = next_sibling > move_to_right_of(next_sib) if next_sib > end > > # Moves a node one down amongst its siblings. Does nothing if it's > already > # the last sibling. > def move_higher > prev_sib = previous_sibling > move_to_left_of(prev_sib) if prev_sib > end > > # Moves a node one to be the first amongst its siblings. Does nothing > if it's already > # the first sibling. > def move_to_top > first_sib = first_sibling > move_to_left_of(first_sib) if first_sib && self != first_sib > end > > # Moves a node one to be the last amongst its siblings. Does nothing > if it's already > # the last sibling. > def move_to_bottom > last_sib = last_sibling > move_to_right_of(last_sib) if last_sib && self != last_sib > end > > These provide the results you'd expect; my first attempt did indeed > cause undesirable movement. > > I'm still a bit stuck with #swap though. It seems like a good method > for distant nodes, but I agree that #move_to should be able to handle > this. Maybe by delegation of #swap to #move_to(target, :swap) ? To be > honest, the #swap method is a snippet of code I gathered some time > ago, not sure where I got it from. I guess someone with in-depth > knowledge of the #move_to internals should be able to incorporate > a :swap option easily. Then, it would probably even work at different > levels, whilst the current version is restricted to the same level > (siblings). That would be awesome. > > - Fabien > > From chriso1515 at gmail.com Sun Jan 14 14:56:35 2007 From: chriso1515 at gmail.com (Chris O'Connor) Date: Sun, 14 Jan 2007 14:56:35 -0500 Subject: [Betternestedset-talk] Noob with trouble getting started with BetterNestedSet Message-ID: Hello all, Would love to use this plugin--looks exactly like what is needed to model a given site's hierarchy. And yet, as a noob (on many levels), I'm having a particularly hard time getting started with it. A tutorial that walked through scaffolding and basic presentation (start to finish) would be SO helpful. For example, my migration throws an error when I try to apply the :scope => :root_id in the model, as shown in the example given at http://wiki.rubyonrails.org/rails/pages/BetterNestedSet. If I remove that scope qualification, I can play with it in the console window, and I BELIEVE I understand the creation sequence and methods, but when it comes to putting together solid scaffolding for this model and actually SHOWING the FULL tree (or even partial trees from a particular node), I get lost quickly. And how does one remove a node cleanly? Any help would be appreciated. And thanks for your patience. -- Chris O'Connor http://www.choipaint.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20070114/0570d31b/attachment.html From dontfall at gmail.com Sun Jan 14 17:09:35 2007 From: dontfall at gmail.com (Krishna Dole) Date: Sun, 14 Jan 2007 17:09:35 -0500 Subject: [Betternestedset-talk] Noob with trouble getting started with BetterNestedSet In-Reply-To: References: Message-ID: <8d64b97d0701141409jb75e3fctceef38681b6e42d8@mail.gmail.com> Hey Chris, Welcome to the list. I agree we need a nice walk-through tutorial. Our code may undergo some changes soon though, so I'm sort of waiting until thing settle out before putting it together. > For example, my migration throws an error when I try to apply the :scope => > :root_id in the model, as shown in the example given at > http://wiki.rubyonrails.org/rails/pages/BetterNestedSet. What error are you seeing? Remember that you only need a scope if you are working with multiple trees. > > If I remove that scope qualification, I can play with it in the console > window, and I BELIEVE I understand the creation sequence and methods, but > when it comes to putting together solid scaffolding for this model and > actually SHOWING the FULL tree (or even partial trees from a particular > node), I get lost quickly. And how does one remove a node cleanly? It is up to you how you want to display the tree, but as a basic example for showing the whole tree: @items = SetModel.root.full_set then in the view you would loop through @items, and, quoting JCM: "You can use style="margin-left:<%= item.level %>em;" in your view to have items indented according to their level." (There are performance problems with calling #level so many times, but it should get you started). If you want an AJAX tree viewer, LiveTree is a Rails plugin that works nicely with nested sets: http://www.epiphyte.ca/code/live_tree.html The plugin handles cleanly deleting nodes for you (there is a callback that destroys all descendants), so just call node.destroy. k From jc.michel at symetrie.com Sun Jan 14 17:31:45 2007 From: jc.michel at symetrie.com (Jean-Christophe Michel) Date: Sun, 14 Jan 2007 23:31:45 +0100 Subject: [Betternestedset-talk] transactions Message-ID: <5fbd15289d095ee63e530098b16bdf70@symetrie.com> Hi Krishna, Don't you think we should use a transaction for the before_destroy action ? Two successive actions in sql should imho always be embeded into a transaction. Jean-Christophe Michel -- symetrie.com Better Nested Set for rails: http://opensource.symetrie.com/trac/better_nested_set From dontfall at gmail.com Sun Jan 14 18:21:29 2007 From: dontfall at gmail.com (Krishna Dole) Date: Sun, 14 Jan 2007 18:21:29 -0500 Subject: [Betternestedset-talk] transactions In-Reply-To: <5fbd15289d095ee63e530098b16bdf70@symetrie.com> References: <5fbd15289d095ee63e530098b16bdf70@symetrie.com> Message-ID: <8d64b97d0701141521h60308c11t4873755bde733712@mail.gmail.com> Hey Jean-Christophe, I think #destroy, #save, etc. are already wrapped in a transaction by Rails. Is this not what you're seeing? k On 1/14/07, Jean-Christophe Michel wrote: > Hi Krishna, > > Don't you think we should use a transaction for the before_destroy > action ? > Two successive actions in sql should imho always be embeded into a > transaction. > > Jean-Christophe Michel > -- > symetrie.com > > Better Nested Set for rails: > http://opensource.symetrie.com/trac/better_nested_set > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > From jc.michel at symetrie.com Sun Jan 14 17:22:17 2007 From: jc.michel at symetrie.com (Jean-Christophe Michel) Date: Sun, 14 Jan 2007 23:22:17 +0100 Subject: [Betternestedset-talk] Noob with trouble getting started with BetterNestedSet In-Reply-To: References: Message-ID: <74af4b6f30d26df65f6894a6def06e4f@symetrie.com> Hi, Le 14 janv. 07, ? 20:56, Chris O'Connor a ?crit : > For example, my migration throws an error when I try to apply the > :scope => :root_id in the model, as shown in the example given at > http://wiki.rubyonrails.org/rails/pages/BetterNestedSet. WHat error ? are you sure your table has a root_id entry ? > If I remove that scope qualification, I can play with it in the > console window, and I BELIEVE I understand the creation sequence and > methods, but when it comes to putting together solid scaffolding for > this model and actually SHOWING the FULL tree (or even partial trees > from a particular node), I get lost quickly. See the helper to do such thing. We will post additional examples on how to display and edit a whole tree soon. > And how does one remove a node cleanly? my_node.destroy Jean-Christophe Michel -- symetrie.com Better Nested Set for rails: http://opensource.symetrie.com/trac/better_nested_set From ruby.on.rails at frayzhe.net Thu Jan 18 20:02:39 2007 From: ruby.on.rails at frayzhe.net (Dustin Frazier) Date: Thu, 18 Jan 2007 17:02:39 -0800 Subject: [Betternestedset-talk] ez-set and scope, helpful code Message-ID: <002901c73b65$848ac0d0$a201a8c0@frayzhe> I recently discovered BetterNestedSet and this mailing list while looking for a simple way to manage a hierarchy of categories for a project management solution I'm working on. I'm very intrigued by the new ez-set version, since IMHO the interface is much simpler than the previous set of methods. I'm all in favor of making a *better* API rather than trying to match acts_as_tree. One question: Does the concept of scope still apply in ez-set? I tried using it with multiple root nodes and no scope, and it seems to work fine, but I'm not sure if it's just a coincidence with how I have my initial data setup. I haven't written much code yet to move nodes around, re-/un-root subtrees, etc. Also, I thought I'd share a bit of migration code that might be useful to others or when you go about writing a step-by-step setup guide. It's a method I added to my CreateCategories migration class that makes it really easy to create leaf nodes along with all parents up the tree: def self.create_category (path) parent = nil path.split(':').each do |name| cat = Category.find_or_create_by_name_and_parent_id(name, parent) parent.children << cat if !parent.nil? parent = cat end end I call this from my "up" method to create leaf nodes: create_category('Infrastructure:Hardware:Servers') create_category('Infrastructure:Software:Windows XP') ... Seems to work, but do let me know if I'm missing some subtly of the new API. Thanks for the great plugin(s)! Keep us posted on the feedback on ez-set... Dustin From dontfall at gmail.com Fri Jan 19 17:37:30 2007 From: dontfall at gmail.com (Krishna Dole) Date: Fri, 19 Jan 2007 17:37:30 -0500 Subject: [Betternestedset-talk] ez-set and scope, helpful code In-Reply-To: <002901c73b65$848ac0d0$a201a8c0@frayzhe> References: <002901c73b65$848ac0d0$a201a8c0@frayzhe> Message-ID: <8d64b97d0701191437j67781072y827f4f36e2e10549@mail.gmail.com> Hi Dustin, Thanks for your comments, and we're glad you've been enjoying the plugin. > methods. I'm all in favor of making a *better* API rather than trying to > match acts_as_tree. Actually, the ez-set branch matches the acts_as_tree API much more closely than trunk does. > > One question: Does the concept of scope still apply in ez-set? Yes. All that stuff works the same. > def self.create_category (path) > parent = nil > path.split(':').each do |name| > cat = Category.find_or_create_by_name_and_parent_id(name, parent) > parent.children << cat if !parent.nil? > parent = cat > end > end Hey, that looks neat. If you wanted to you could post it on the wiki page: http://wiki.rubyonrails.org/rails/pages/BetterNestedSet Cheers, Krishna From philippe.lang at attiksystem.ch Mon Jan 22 12:44:54 2007 From: philippe.lang at attiksystem.ch (Philippe Lang) Date: Mon, 22 Jan 2007 18:44:54 +0100 Subject: [Betternestedset-talk] Bug after upgrade? Message-ID: <6C0CF58A187DA5479245E0830AF84F421D1716@poweredge.attiksystem.ch> Hi, After upgrading to the latest BetterNestedSet library, today, I suddently start having problems using it. The following code gives an error where indicated. It used to works just fine with an older version. Is that a problem due to the new activerecord library I have installed as well? Does anyone have an idea of what happened? ---------------------------------- product_type_base = ProductType.new product_type_base.name = "base" product_type_base.lookup = "b" product_type_base.save product_type_1 = ProductType.new product_type_1.name = "ass?chement" product_type_1.lookup = "ass" product_type_1.save product_type_11 = ProductType.new product_type_11.name = "ass?chement location" product_type_11.lookup = "loc" product_type_11.save product_type_12 = ProductType.new product_type_12.name = "ass?chement apr?s d?g?ts d'eau" product_type_12.lookup = "deg" product_type_12.save product_type_2 = ProductType.new product_type_2.name = "d?shumidification" product_type_2.lookup = "des" product_type_2.save product_type_21 = ProductType.new product_type_21.name = "d?shumidification escolino" product_type_21.lookup = "esl" product_type_21.save product_type_22 = ProductType.new product_type_22.name = "d?shumidification escocompact" product_type_22.lookup = "esc" product_type_22.save product_type_3 = ProductType.new product_type_3.name = "abris pc" product_type_3.lookup = "abr" product_type_3.save product_type_1.move_to_child_of(product_type_base) <-------- ERROR HERE product_type_2.move_to_child_of(product_type_base) product_type_3.move_to_child_of(product_type_base) product_type_11.move_to_child_of(product_type_1) product_type_12.move_to_child_of(product_type_1) product_type_21.move_to_child_of(product_type_2) product_type_22.move_to_child_of(product_type_2) ---------------------------------- c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/connection_ adapters/abstract_adapter.rb:128:in `log': RuntimeError: ERROR C42703 Mcolumn "product_types" of relation "product_types" does not exist Fparse_relation. c L1728 RattnameAttNum: UPDATE product_types SET product_t ypes.lft = CASE WHEN product_types.lft BETWEEN 2 AND 2 THEN prod uct_types.lft + 2 WHEN product_types.lft BETWEEN 3 AND 4 THEN pr oduct_types.lft + -1 ELSE product_types.lft END, p roduct_types.rgt = CASE WHEN product_types.rgt BETWEEN 2 AND 2 T HEN product_types.rgt + 2 WHEN product_types.rgt BETWEEN 3 AND 4 THEN product_types.rgt + -1 ELSE product_types.rgt END, product_types.parent_id = CASE WHEN id = 2 THEN 1 ELSE product_types.parent_id END WHERE (1 = 1) (ActiveRecord::Statemen tInvalid) from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor d/connection_adapters/postgresql_adapter.rb:152:in `execute' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor d/connection_adapters/postgresql_adapter.rb:162:in `update' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor d/base.rb:494:in `update_all' from ../../lib/data/better_nested_set/trunk/lib/better_nested_set.rb:736 :in `move_to' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor d/connection_adapters/abstract/database_statements.rb:59:in `transaction' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor d/transactions.rb:95:in `transaction' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor d/transactions.rb:121:in `transaction' from ../../lib/data/better_nested_set/trunk/lib/better_nested_set.rb:691 :in `move_to' from ../../lib/data/better_nested_set/trunk/lib/better_nested_set.rb:624 :in `move_to_child_of' from insert_data.rb:89 From dontfall at gmail.com Mon Jan 22 15:02:21 2007 From: dontfall at gmail.com (Krishna Dole) Date: Mon, 22 Jan 2007 15:02:21 -0500 Subject: [Betternestedset-talk] Bug after upgrade? In-Reply-To: <6C0CF58A187DA5479245E0830AF84F421D1716@poweredge.attiksystem.ch> References: <6C0CF58A187DA5479245E0830AF84F421D1716@poweredge.attiksystem.ch> Message-ID: <8d64b97d0701221202r6c22282cs1ab74bd555383178@mail.gmail.com> Hi Phillipe, I think it is a PostgreSQL-specific problem, since I got the error you reported when using PgSQL, but not under MySQL. I'm looking into it now. Krishna On 1/22/07, Philippe Lang wrote: > Hi, > > After upgrading to the latest BetterNestedSet library, today, I suddently start having problems using it. The following code gives an error where indicated. It used to works just fine with an older version. > > > Is that a problem due to the new activerecord library I have installed as well? > > Does anyone have an idea of what happened? > > > ---------------------------------- > > > product_type_base = ProductType.new > product_type_base.name = "base" > product_type_base.lookup = "b" > product_type_base.save > > product_type_1 = ProductType.new > product_type_1.name = "ass?chement" > product_type_1.lookup = "ass" > product_type_1.save > > product_type_11 = ProductType.new > product_type_11.name = "ass?chement location" > product_type_11.lookup = "loc" > product_type_11.save > > product_type_12 = ProductType.new > product_type_12.name = "ass?chement apr?s d?g?ts d'eau" > product_type_12.lookup = "deg" > product_type_12.save > > product_type_2 = ProductType.new > product_type_2.name = "d?shumidification" > product_type_2.lookup = "des" > product_type_2.save > > product_type_21 = ProductType.new > product_type_21.name = "d?shumidification escolino" > product_type_21.lookup = "esl" > product_type_21.save > > product_type_22 = ProductType.new > product_type_22.name = "d?shumidification escocompact" > product_type_22.lookup = "esc" > product_type_22.save > > product_type_3 = ProductType.new > product_type_3.name = "abris pc" > product_type_3.lookup = "abr" > product_type_3.save > > product_type_1.move_to_child_of(product_type_base) <-------- ERROR HERE > product_type_2.move_to_child_of(product_type_base) > product_type_3.move_to_child_of(product_type_base) > product_type_11.move_to_child_of(product_type_1) > product_type_12.move_to_child_of(product_type_1) > product_type_21.move_to_child_of(product_type_2) > product_type_22.move_to_child_of(product_type_2) > > > ---------------------------------- > > > c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/connection_ > adapters/abstract_adapter.rb:128:in `log': RuntimeError: ERROR C42703 Mcolumn > "product_types" of relation "product_types" does not exist Fparse_relation. > c L1728 RattnameAttNum: UPDATE product_types SET product_t > ypes.lft = CASE WHEN product_types.lft BETWEEN 2 AND 2 THEN prod > uct_types.lft + 2 WHEN product_types.lft BETWEEN 3 AND 4 THEN pr > oduct_types.lft + -1 ELSE product_types.lft END, p > roduct_types.rgt = CASE WHEN product_types.rgt BETWEEN 2 AND 2 T > HEN product_types.rgt + 2 WHEN product_types.rgt BETWEEN 3 AND 4 > THEN product_types.rgt + -1 ELSE product_types.rgt END, > product_types.parent_id = CASE WHEN id = 2 THEN 1 > ELSE product_types.parent_id END WHERE (1 = 1) (ActiveRecord::Statemen > tInvalid) > from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor > d/connection_adapters/postgresql_adapter.rb:152:in `execute' > from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor > d/connection_adapters/postgresql_adapter.rb:162:in `update' > from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor > d/base.rb:494:in `update_all' > from ../../lib/data/better_nested_set/trunk/lib/better_nested_set.rb:736 > :in `move_to' > from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor > d/connection_adapters/abstract/database_statements.rb:59:in `transaction' > from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor > d/transactions.rb:95:in `transaction' > from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor > d/transactions.rb:121:in `transaction' > from ../../lib/data/better_nested_set/trunk/lib/better_nested_set.rb:691 > :in `move_to' > from ../../lib/data/better_nested_set/trunk/lib/better_nested_set.rb:624 > :in `move_to_child_of' > from insert_data.rb:89 > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > From dontfall at gmail.com Mon Jan 22 18:11:52 2007 From: dontfall at gmail.com (Krishna Dole) Date: Mon, 22 Jan 2007 18:11:52 -0500 Subject: [Betternestedset-talk] Bug after upgrade? In-Reply-To: <8d64b97d0701221202r6c22282cs1ab74bd555383178@mail.gmail.com> References: <6C0CF58A187DA5479245E0830AF84F421D1716@poweredge.attiksystem.ch> <8d64b97d0701221202r6c22282cs1ab74bd555383178@mail.gmail.com> Message-ID: <8d64b97d0701221511g49aadcdbhb6365f1f78f528d1@mail.gmail.com> Just so everyone on the list knows, Fabien fixed the problem, and the current trunk version (43) plays nicely with SQLite3 and PostgreSQL again. Cheers, Krishna On 1/22/07, Krishna Dole wrote: > Hi Phillipe, > > I think it is a PostgreSQL-specific problem, since I got the error you > reported when using PgSQL, but not under MySQL. > > I'm looking into it now. > > Krishna > > On 1/22/07, Philippe Lang wrote: > > Hi, > > > > After upgrading to the latest BetterNestedSet library, today, I suddently start having problems using it. The following code gives an error where indicated. It used to works just fine with an older version. > > > > > > Is that a problem due to the new activerecord library I have installed as well? > > > > Does anyone have an idea of what happened? > > > > > > ---------------------------------- > > > > > > product_type_base = ProductType.new > > product_type_base.name = "base" > > product_type_base.lookup = "b" > > product_type_base.save > > > > product_type_1 = ProductType.new > > product_type_1.name = "ass?chement" > > product_type_1.lookup = "ass" > > product_type_1.save > > > > product_type_11 = ProductType.new > > product_type_11.name = "ass?chement location" > > product_type_11.lookup = "loc" > > product_type_11.save > > > > product_type_12 = ProductType.new > > product_type_12.name = "ass?chement apr?s d?g?ts d'eau" > > product_type_12.lookup = "deg" > > product_type_12.save > > > > product_type_2 = ProductType.new > > product_type_2.name = "d?shumidification" > > product_type_2.lookup = "des" > > product_type_2.save > > > > product_type_21 = ProductType.new > > product_type_21.name = "d?shumidification escolino" > > product_type_21.lookup = "esl" > > product_type_21.save > > > > product_type_22 = ProductType.new > > product_type_22.name = "d?shumidification escocompact" > > product_type_22.lookup = "esc" > > product_type_22.save > > > > product_type_3 = ProductType.new > > product_type_3.name = "abris pc" > > product_type_3.lookup = "abr" > > product_type_3.save > > > > product_type_1.move_to_child_of(product_type_base) <-------- ERROR HERE > > product_type_2.move_to_child_of(product_type_base) > > product_type_3.move_to_child_of(product_type_base) > > product_type_11.move_to_child_of(product_type_1) > > product_type_12.move_to_child_of(product_type_1) > > product_type_21.move_to_child_of(product_type_2) > > product_type_22.move_to_child_of(product_type_2) > > > > > > ---------------------------------- > > > > > > c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/connection_ > > adapters/abstract_adapter.rb:128:in `log': RuntimeError: ERROR C42703 Mcolumn > > "product_types" of relation "product_types" does not exist Fparse_relation. > > c L1728 RattnameAttNum: UPDATE product_types SET product_t > > ypes.lft = CASE WHEN product_types.lft BETWEEN 2 AND 2 THEN prod > > uct_types.lft + 2 WHEN product_types.lft BETWEEN 3 AND 4 THEN pr > > oduct_types.lft + -1 ELSE product_types.lft END, p > > roduct_types.rgt = CASE WHEN product_types.rgt BETWEEN 2 AND 2 T > > HEN product_types.rgt + 2 WHEN product_types.rgt BETWEEN 3 AND 4 > > THEN product_types.rgt + -1 ELSE product_types.rgt END, > > product_types.parent_id = CASE WHEN id = 2 THEN 1 > > ELSE product_types.parent_id END WHERE (1 = 1) (ActiveRecord::Statemen > > tInvalid) > > from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor > > d/connection_adapters/postgresql_adapter.rb:152:in `execute' > > from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor > > d/connection_adapters/postgresql_adapter.rb:162:in `update' > > from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor > > d/base.rb:494:in `update_all' > > from ../../lib/data/better_nested_set/trunk/lib/better_nested_set.rb:736 > > :in `move_to' > > from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor > > d/connection_adapters/abstract/database_statements.rb:59:in `transaction' > > from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor > > d/transactions.rb:95:in `transaction' > > from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_recor > > d/transactions.rb:121:in `transaction' > > from ../../lib/data/better_nested_set/trunk/lib/better_nested_set.rb:691 > > :in `move_to' > > from ../../lib/data/better_nested_set/trunk/lib/better_nested_set.rb:624 > > :in `move_to_child_of' > > from insert_data.rb:89 > > _______________________________________________ > > Betternestedset-talk mailing list > > Betternestedset-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > From philippe.lang at attiksystem.ch Tue Jan 23 02:17:15 2007 From: philippe.lang at attiksystem.ch (Philippe Lang) Date: Tue, 23 Jan 2007 08:17:15 +0100 Subject: [Betternestedset-talk] Bug after upgrade? References: <6C0CF58A187DA5479245E0830AF84F421D1716@poweredge.attiksystem.ch><8d64b97d0701221202r6c22282cs1ab74bd555383178@mail.gmail.com> <8d64b97d0701221511g49aadcdbhb6365f1f78f528d1@mail.gmail.com> Message-ID: <6C0CF58A187DA5479245E0830AF84F421D171C@poweredge.attiksystem.ch> betternestedset-talk-bounces at rubyforge.org wrote: > Just so everyone on the list knows, Fabien fixed the problem, and the > current trunk version (43) plays nicely with SQLite3 and PostgreSQL > again. > > Cheers, > Krishna Thanks for reacting so quickly! That's great, thanks a lot. It works like a charm again. Philippe From robert.head at gmail.com Tue Jan 30 15:01:58 2007 From: robert.head at gmail.com (Robert Head) Date: Tue, 30 Jan 2007 12:01:58 -0800 Subject: [Betternestedset-talk] Assuring initialization of lft and rgt Message-ID: <43e309bd0701301201hc5ec2c2led16348101f1013d@mail.gmail.com> I'm having trouble setting lft and rgt for root nodes. With betternestedset, you can't access lft and rgt, you have to use move_to_* But using move_to_* when lft or rgt is nil results in an exception. "You cannot move a node if left or right is nil /Users/roberthead/Documents/Projects/icrew_machine/config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:427:in `move_to' /Users/roberthead/Documents/Projects/icrew_machine/config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:421:in `move_to_child_of'..." What am I missing? Many thanks in advance. Robert Head robert.head at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20070130/e3c0c644/attachment.html From dontfall at gmail.com Tue Jan 30 15:21:57 2007 From: dontfall at gmail.com (Krishna Dole) Date: Tue, 30 Jan 2007 15:21:57 -0500 Subject: [Betternestedset-talk] Assuring initialization of lft and rgt In-Reply-To: <43e309bd0701301201hc5ec2c2led16348101f1013d@mail.gmail.com> References: <43e309bd0701301201hc5ec2c2led16348101f1013d@mail.gmail.com> Message-ID: <8d64b97d0701301221k36e3d685s603732118b81e388@mail.gmail.com> Hi Robert, The lft and rgt values are set for new records when they are saved: i = Item.new # lft and rgt are nil i.save # lft = 1, rgt = 2 if you have a table with preexisting records that don't have lft or rgt, you can use the SetClass.renumber_all method to get things fixed up. (Note that if you have multiple trees, you need to make sure that all members of each tree have the same scope value before doing this). Cheers, Krishna On 1/30/07, Robert Head wrote: > I'm having trouble setting lft and rgt for root nodes. > > With betternestedset, you can't access lft and rgt, you have to use > move_to_* > > But using move_to_* when lft or rgt is nil results in an exception. > > "You cannot move a node if left or right is nil > /Users/roberthead/Documents/Projects/icrew_machine/config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:427:in > `move_to' > /Users/roberthead/Documents/Projects/icrew_machine/config/../vendor/plugins/betternestedset/lib/better_nested_set.rb:421:in > `move_to_child_of'..." > > What am I missing? > > Many thanks in advance. > > Robert Head > robert.head at gmail.com > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > From chriso1515 at gmail.com Tue Jan 30 22:54:30 2007 From: chriso1515 at gmail.com (Chris O'Connor) Date: Tue, 30 Jan 2007 22:54:30 -0500 Subject: [Betternestedset-talk] Noob with trouble getting started with BetterNestedSet In-Reply-To: <8d64b97d0701141409jb75e3fctceef38681b6e42d8@mail.gmail.com> References: <8d64b97d0701141409jb75e3fctceef38681b6e42d8@mail.gmail.com> Message-ID: Thanks to all for the replies, I've been on another project and haven't had time to come back to this, but now here I am again. With a class called 'TreeItem', (table: 'tree_items'), and simple input from the console I get this error: # from ruby console window >> child = TreeItem.new(:name => "my_computer") SyntaxError: ./script/../config/../config/../app/models/tree_item.rb:2: parse er ror, unexpected tASSOC, expecting tCOLON2 or '[' or '.' acts_as_nested_set, :scope => :root_id ^ from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- 1.3.1.584 8/lib/active_support/dependencies.rb:204:in `load_without_new_constant_marking' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- 1.3.1.584 8/lib/active_support/dependencies.rb:204:in `load_file' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- 1.3.1.584 8/lib/active_support/dependencies.rb:343:in `new_constants_in' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- 1.3.1.584 8/lib/active_support/dependencies.rb:203:in `load_file' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- 1.3.1.584 8/lib/active_support/dependencies.rb:95:in `require_or_load' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- 1.3.1.584 8/lib/active_support/dependencies.rb:249:in `load_missing_constant' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- 1.3.1.584 8/lib/active_support/dependencies.rb:453:in `const_missing' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- 1.3.1.584 8/lib/active_support/dependencies.rb:465:in `const_missing' from (irb):3 >> My model file: #tree_item.rb class TreeItem < ActiveRecord::Base acts_as_nested_set, :scope => :root_id end my data in mysql from monitor: mysql> select * from tree_items; +----+---------+-----------+------+------+------------------------+ | id | root_id | parent_id | lft | rgt | name | +----+---------+-----------+------+------+------------------------+ | 1 | 1 | NULL | 1 | 2 | ruby | | 2 | 2 | NULL | 1 | 2 | rails | | 3 | 3 | NULL | 1 | 6 | computers | | 4 | 3 | 3 | 2 | 3 | apple | | 5 | 3 | 3 | 4 | 5 | dell | | 6 | 6 | NULL | 1 | 8 | rails plug-ins | | 7 | 6 | 6 | 2 | 3 | better_nested_set | | 8 | 8 | NULL | 1 | 2 | frameworks | | 9 | 6 | 6 | 4 | 5 | restful_authentication | | 10 | 6 | 6 | 6 | 7 | authorization | | 11 | 11 | NULL | 1 | 2 | databases | +----+---------+-----------+------+------+------------------------+ 11 rows in set (0.13 sec) (you'll have to trust me I guess)... What's more curious is if I remove the :scope => :root_id I can work with the console all i like--making new children, saving them and moving them to others. I can even list the items in a view; however, they are not in the order I would hope for (due to no scope, yes?). Is there something obvious I'm missing? Thanks, Chris On 1/14/07, Krishna Dole wrote: > > Hey Chris, > > Welcome to the list. I agree we need a nice walk-through tutorial. Our > code may undergo some changes soon though, so I'm sort of waiting > until thing settle out before putting it together. > > > For example, my migration throws an error when I try to apply the :scope > => > > :root_id in the model, as shown in the example given at > > http://wiki.rubyonrails.org/rails/pages/BetterNestedSet. > > What error are you seeing? Remember that you only need a scope if you > are working with multiple trees. > > > > > If I remove that scope qualification, I can play with it in the console > > window, and I BELIEVE I understand the creation sequence and methods, > but > > when it comes to putting together solid scaffolding for this model and > > actually SHOWING the FULL tree (or even partial trees from a particular > > node), I get lost quickly. And how does one remove a node cleanly? > > It is up to you how you want to display the tree, but as a basic > example for showing the whole tree: > @items = SetModel.root.full_set > then in the view you would loop through @items, and, quoting JCM: "You > can use style="margin-left:<%= item.level %>em;" in your view to have > items indented according to their level." (There are performance > problems with calling #level so many times, but it should get you > started). > > If you want an AJAX tree viewer, LiveTree is a Rails plugin that works > nicely with nested sets: > http://www.epiphyte.ca/code/live_tree.html > > The plugin handles cleanly deleting nodes for you (there is a callback > that destroys all descendants), so just call node.destroy. > > k > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > -- Chris O'Connor 718.788.4817 chriso1515 at gmail.com http://www.choipaint.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20070130/f2629872/attachment.html From dontfall at gmail.com Wed Jan 31 09:53:15 2007 From: dontfall at gmail.com (Krishna Dole) Date: Wed, 31 Jan 2007 09:53:15 -0500 Subject: [Betternestedset-talk] Noob with trouble getting started with BetterNestedSet In-Reply-To: References: <8d64b97d0701141409jb75e3fctceef38681b6e42d8@mail.gmail.com> Message-ID: <8d64b97d0701310653x386c021ft7aad3f8e8b81bd45@mail.gmail.com> Hey Chris, Try removing the comma from acts_as_nested_set, :scope => :root_id Cheers, k On 1/30/07, Chris O'Connor wrote: > Thanks to all for the replies, > > I've been on another project and haven't had time to come back to this, but > now here I am again. > > With a class called 'TreeItem', (table: 'tree_items'), and simple input from > the console I get this error: > > # from ruby console window > > > >> child = TreeItem.new(:name => "my_computer") > SyntaxError: > ./script/../config/../config/../app/models/tree_item.rb:2: > parse er > ror, unexpected tASSOC, expecting tCOLON2 or '[' or '.' > acts_as_nested_set, :scope => :root_id > ^ > from > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1.584 > 8/lib/active_support/dependencies.rb:204:in > `load_without_new_constant_marking' > from > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1.584 > 8/lib/active_support/dependencies.rb:204:in `load_file' > from > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- > 1.3.1.584 > 8/lib/active_support/dependencies.rb:343:in > `new_constants_in' > from > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1.584 > 8/lib/active_support/dependencies.rb:203:in `load_file' > from > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1.584 > 8/lib/active_support/dependencies.rb:95:in > `require_or_load' > from > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport- > 1.3.1.584 > 8/lib/active_support/dependencies.rb:249:in > `load_missing_constant' > from > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1.584 > 8/lib/active_support/dependencies.rb:453:in `const_missing' > from > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1.584 > 8/lib/active_support/dependencies.rb:465:in `const_missing' > from (irb):3 > >> > > My model file: > > #tree_item.rb > > class TreeItem < ActiveRecord::Base > acts_as_nested_set, :scope => :root_id > > end > > my data in mysql from monitor: > > mysql> select * from tree_items; > +----+---------+-----------+------+------+------------------------+ > | id | root_id | parent_id | lft | rgt | name | > +----+---------+-----------+------+------+------------------------+ > | 1 | 1 | NULL | 1 | 2 | ruby | > | 2 | 2 | NULL | 1 | 2 | rails | > | 3 | 3 | NULL | 1 | 6 | computers | > | 4 | 3 | 3 | 2 | 3 | apple | > | 5 | 3 | 3 | 4 | 5 | dell | > | 6 | 6 | NULL | 1 | 8 | rails plug-ins | > | 7 | 6 | 6 | 2 | 3 | better_nested_set | > | 8 | 8 | NULL | 1 | 2 | frameworks | > | 9 | 6 | 6 | 4 | 5 | restful_authentication | > | 10 | 6 | 6 | 6 | 7 | authorization | > | 11 | 11 | NULL | 1 | 2 | databases | > +----+---------+-----------+------+------+------------------------+ > 11 rows in set (0.13 sec) > (you'll have to trust me I guess)... > > What's more curious is if I remove the :scope => :root_id I can work with > the console all i like--making new children, saving them and moving them to > others. I can even list the items in a view; however, they are not in the > order I would hope for (due to no scope, yes?). > > Is there something obvious I'm missing? > > Thanks, > Chris > > > > > > On 1/14/07, Krishna Dole < dontfall at gmail.com> wrote: > > > > Hey Chris, > > > > Welcome to the list. I agree we need a nice walk-through tutorial. Our > > code may undergo some changes soon though, so I'm sort of waiting > > until thing settle out before putting it together. > > > > > For example, my migration throws an error when I try to apply the :scope > => > > > :root_id in the model, as shown in the example given at > > > > http://wiki.rubyonrails.org/rails/pages/BetterNestedSet. > > > > What error are you seeing? Remember that you only need a scope if you > > are working with multiple trees. > > > > > > > > If I remove that scope qualification, I can play with it in the console > > > window, and I BELIEVE I understand the creation sequence and methods, > but > > > when it comes to putting together solid scaffolding for this model and > > > actually SHOWING the FULL tree (or even partial trees from a particular > > > node), I get lost quickly. And how does one remove a node cleanly? > > > > It is up to you how you want to display the tree, but as a basic > > example for showing the whole tree: > > @items = SetModel.root.full_set > > then in the view you would loop through @items, and, quoting JCM: "You > > can use style="margin-left:<%= item.level %>em;" in your view to have > > items indented according to their level." (There are performance > > problems with calling #level so many times, but it should get you > > started). > > > > If you want an AJAX tree viewer, LiveTree is a Rails plugin that works > > nicely with nested sets: > > http://www.epiphyte.ca/code/live_tree.html > > > > The plugin handles cleanly deleting nodes for you (there is a callback > > that destroys all descendants), so just call node.destroy. > > > > k > > _______________________________________________ > > Betternestedset-talk mailing list > > Betternestedset-talk at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > -- > Chris O'Connor > 718.788.4817 > chriso1515 at gmail.com > http://www.choipaint.com/ > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > >