From wschenk at gmail.com Mon Oct 1 11:05:32 2007 From: wschenk at gmail.com (Will Schenk) Date: Mon, 1 Oct 2007 11:05:32 -0400 Subject: [Betternestedset-talk] (no subject) In-Reply-To: <8d64b97d0709302032t263cff27xf1effaa4d0512252@mail.gmail.com> References: <8d64b97d0709302032t263cff27xf1effaa4d0512252@mail.gmail.com> Message-ID: I was at RailsConf Berlin and they were saying that they have a new process to get patches in. I need to look up the info in more detail, but basically you need to have each patch verified by at least three people and it gets onto "Report 12". I think that if we all hammer out something here and we're all happy with it, and especially figure out how to make it compatible with the old one it won't be an issue. I like the idea of having an easy-to-use API built on top of something more powerful than what is currently in core. I think with 3 people working on this here (if Jean Christophe is interested) we should have no problems. -w On Sep 30, 2007, at 11:32 PM, Krishna Dole wrote: > Hi Will, > > Nice to hear from you. In summary, I agree that the plugins should be > merged, and I'm happy to help. > > My part of the story starts about 2 years ago. I wanted a nested set, > but I needed to be able to move subtrees and add numbers to existing > trees to turn them into nested sets. I modified and added to your code > to do this, but didn't release my changes. A while later I discovered > Jean-Christophe Michel's BetterNestedSet, which had an improved way of > moving subtrees. I started working with him, adding various > functionality and tests. > > BetterNestedSet has a number of advantages over the original. Perhaps > the most important is the ability to move subtrees around. Other > improvements include concurrency-safety (critical for high-traffic > applications, since nested sets are so volatile), the ability to > re-order siblings for acts_as_list functionality, methods for checking > and re-numbering trees, and probably other important things I've > forgotten. > > As a side note, I also wrote a modified version[1] of BNS that > provides an even simpler API-- you just treat your model like an > acts_as_tree, and AR callbacks handle all the nested set operations > completely transparently. You can use all the methods added by > belongs_to and has_many, and it just works. I still really like this > idea, but I haven't had time to see how much of a performance hit it > causes. > > I think the questions that need to be resolved before merging BNS into > an official plugin are: > 1) Is the core team willing to cooperate with this? I think BNS was > originally created because the overworked core team didn't commit > Jean-Christphe's patches. > > 2) There are a few minor compatibility breakages between AANS and BNS > that we would likely want to look at. > > Does anyone else have concerns to raise? > > Krishna > > > [1] svn://rubyforge.org/var/svn/betternestedset/branches/ez-set/ > > > > On 9/30/07, Will Schenk wrote: >> Hi all, >> >> I wrote the original acts_as_nested_set over a weekend it looks >> like 2.5 >> years ago[1] and then sort of fell off the face of the earth. No >> one else >> has touched it as far as I can see and people seemed to have >> missed how to >> use the :scope parameter. Next time I guess I should have more >> documentation, though I do enjoy that my little ASCII diagram as >> made it >> around! I have need for it again and the core for original reason >> that I >> needed it is long gone and for rails 0.9 anyway. So I've been >> looking to >> see whats out there and there's acts_as_threaded and >> betternestedset. I >> can't seem to find acts_as_threaded (the url doesn't work?). >> >> My question is do we need to have two plugins for this? What >> exactly is >> better about BetterNestedSet? (I'm curious. The move_to_child_of >> seems >> more complicated to me than just saying o.add_child, but having >> access to >> the level seems nice.) >> >> Anyway, acts_as_nested_set has been moved to an official plugin at >> http://dev.rubyonrails.org/browser/plugins/acts_as_nested_set >> and it seems to me that it would be easier for everyone if we just >> merged >> the two somehow. >> -w >> >> [1] http://dev.rubyonrails.org/ticket/1000 Holy crap >> that's a while ago! >> >> Will Schenk >> wschenk at gmail.com >> http://sublimeguile.com >> >> _______________________________________________ >> Betternestedset-talk mailing list >> Betternestedset-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/betternestedset-talk >> >> > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk Will Schenk wschenk at gmail.com http://sublimeguile.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071001/5f4f5eca/attachment.html From tolsen718 at gmail.com Mon Oct 1 11:13:47 2007 From: tolsen718 at gmail.com (Tim Olsen) Date: Mon, 1 Oct 2007 11:13:47 -0400 Subject: [Betternestedset-talk] (no subject) In-Reply-To: References: <8d64b97d0709302032t263cff27xf1effaa4d0512252@mail.gmail.com> Message-ID: <4be80d840710010813o118a9b31va4ddd0cc6915d86e@mail.gmail.com> On 10/1/07, Will Schenk wrote: > I was at RailsConf Berlin and they were saying that they have a new process > to get patches in. I need to look up the info in more detail, but basically > you need to have each patch verified by at least three people and it gets > onto "Report 12". I think that if we all hammer out something here and http://weblog.rubyonrails.com/2007/9/15/how-to-get-a-patch-into-rails -Tim From cnk at caltech.edu Mon Oct 1 16:28:27 2007 From: cnk at caltech.edu (Cynthia Kiser) Date: Mon, 1 Oct 2007 13:28:27 -0700 Subject: [Betternestedset-talk] /tangent In-Reply-To: References: Message-ID: <20071001202827.GC10062@sue.caltech.edu> I am not quite ready to write/improve plugins myself. But I am getting there. If you guys want an alpha tester, I could try out the new integrated plugin and try to generate good issue reports. Actually, I have a design question/suggestion for the current betternestedset. Quoting Will Schenk : > What exactly is better about BetterNestedSet? (I'm curious. The > move_to_child_of seems more complicated to me than just saying > o.add_child, but having access to the level seems nice.) Why is setting of parent_id directly prohibited? I have a before_save filter that needs information from parent_id to work, but I can't set it in the object. Wills post reminded me of the add_child method, so I checked to see if that would prevent me having to do 3 saves to create my object (the original save, the move_to_child_of save, and then an additional, gratuitous save to get my filter to run), but I couldn't actually get it to work at all. If it is neccessary to protect setting parent_id, is it possible to put in some sort of registered callbacks? I am thinking of the code I noticed in attachment_fu that lets you configure a block that is called before a thumbnail is saved. It made it really easy for me to add some metadata to the automatically generated thumbnails before they were saved to the database. Example: before_thumbnail_saved do |record, thumbnail| thumbnail.title = record.title thumbnail.description = record.description thumbnail.user_id = record.user_id end -- Cynthia Kiser From justin at maccarthy.org Wed Oct 3 13:51:56 2007 From: justin at maccarthy.org (Justin MacCarthy) Date: Wed, 3 Oct 2007 18:51:56 +0100 Subject: [Betternestedset-talk] What is the best why to get the fullpath back to the root Message-ID: <9e9015d40710031051r3936cd43hdb4f0387aa876fb6@mail.gmail.com> Newbie, Doing a site map type structure, as I'm sure many of you have too .. Need breadcrumbs and to do lookups on a node by full path e.g (home)/about_us/our_mission and Home / About us / Our mission for example (assuming Home is the label attribute, of a model Menu) Also anyone caching entire menus in a instance var ? Any advice? Thanks Justin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071003/1c4ba3c2/attachment-0001.html From dontfall at gmail.com Wed Oct 3 14:32:12 2007 From: dontfall at gmail.com (Krishna Dole) Date: Wed, 3 Oct 2007 11:32:12 -0700 Subject: [Betternestedset-talk] What is the best why to get the fullpath back to the root In-Reply-To: <9e9015d40710031051r3936cd43hdb4f0387aa876fb6@mail.gmail.com> References: <9e9015d40710031051r3936cd43hdb4f0387aa876fb6@mail.gmail.com> Message-ID: <8d64b97d0710031132y62965e1fm5d0dfb5bd0d9c332@mail.gmail.com> Hey Justin-- model.ancestors will give the path back to the root. Krishna On 10/3/07, Justin MacCarthy wrote: > Newbie, > > Doing a site map type structure, as I'm sure many of you have too .. > > Need breadcrumbs and to do lookups on a node by full path e.g > > > (home)/about_us/our_mission > > and > > Home / About us / Our mission > > for example (assuming Home is the label attribute, of a model Menu) > > Also anyone caching entire menus in a instance var ? Any advice? > > > > Thanks Justin > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > From serg-e at ukr.net Thu Oct 4 08:27:37 2007 From: serg-e at ukr.net (Serge) Date: Thu, 04 Oct 2007 15:27:37 +0300 Subject: [Betternestedset-talk] just a test Message-ID: <4704DC39.8020409@ukr.net> test From lists.jc.michel at symetrie.com Thu Oct 4 13:00:37 2007 From: lists.jc.michel at symetrie.com (Jean-Christophe Michel) Date: Thu, 4 Oct 2007 19:00:37 +0200 Subject: [Betternestedset-talk] =?iso-8859-1?q?R=E9p=3A_/tangent?= Message-ID: Hi, Le 1 oct. 07 ? 22:28, Cynthia Kiser a ?crit : > Why is setting of parent_id directly prohibited? > Iirc, the idea behind all this was to avoid breaking AR logic. In AR objects, setting a property value doesn't save the object, neither does it save or change magically other objects of the same type. Due to the way nested set works, moving a tree impacts more than setting a property value. We preferred to have a heavy explicit method to be used than magic doing some changes in the background. Jean-Christophe Michel From lists.jc.michel at symetrie.com Thu Oct 4 13:01:18 2007 From: lists.jc.michel at symetrie.com (Jean-Christophe Michel) Date: Thu, 4 Oct 2007 19:01:18 +0200 Subject: [Betternestedset-talk] (no subject) In-Reply-To: References: Message-ID: Hi, Thanks Krishna for your summary ! I'm quite busy these days and won't be able to improve BNS just now, but I plan to continue to use it and I agree that merging is a good idea. Le 1 oct. 07 ? 17:05, Will Schenk a ?crit : I was at RailsConf Berlin and they were saying that they have a new process to get patches in. I need to look up the info in more detail, but basically you need to have each patch verified by at least three people and it gets onto "Report 12". I think that if we all hammer out something here and we're all happy with it, and especially figure out how to make it compatible with the old one it won't be an issue. I like the idea of having an easy-to-use API built on top of something more powerful than what is currently in core. I think with 3 people working on this here (if Jean Christophe is interested) we should have no problems. Will, can you tell us wether the plugin you wrote is linked to core now ? is it completely independant or no ? Jean-Christophe Michel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071004/741b362c/attachment.html From leondu at gmail.com Mon Oct 8 02:28:35 2007 From: leondu at gmail.com (leon du) Date: Mon, 8 Oct 2007 14:28:35 +0800 Subject: [Betternestedset-talk] Recursive Menu Example Message-ID: hi all! I am now reading the recursive menu example and got some problem with the code below: ------------------------------------------------------------------------------------ @menus[i] = {:indent => allmenus[i].level, :title => allmenus[i].title, :children_count => allmenus[i].all_children_count, :url => allmenus[i].page ? allmenus[i].page.whole_url : ''} -------------------------------------------------------------------------- but in the database section, I dont see the column definition of 'title' and 'page', so is there somthing missed or is it my misundstanding? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071008/4c064b19/attachment.html From alkondratenko at gmail.com Mon Oct 8 06:44:58 2007 From: alkondratenko at gmail.com (Aleksey Kondratenko) Date: Mon, 08 Oct 2007 13:44:58 +0300 Subject: [Betternestedset-talk] [patch] don't invoke #destroy twice on tree nodes Message-ID: <1191840298.25655.6.camel@gamma.altoros.corp> Patch is against r77. In current version of plugin #destroy'ing tree nodes causes it to be actually destroyed twice. This means that after_destroy callbacks will also be called twice. The patch fixes it. -------------- next part -------------- A non-text attachment was scrubbed... Name: destroys_twice_fix.patch Type: text/x-patch Size: 1413 bytes Desc: not available Url : http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071008/46112992/attachment.bin From alkondratenko at gmail.com Mon Oct 8 06:52:35 2007 From: alkondratenko at gmail.com (Aleksey Kondratenko) Date: Mon, 08 Oct 2007 13:52:35 +0300 Subject: [Betternestedset-talk] [patch] fix for latest rails edge Message-ID: <1191840755.25655.12.camel@gamma.altoros.corp> After fix for http://dev.rubyonrails.org/ticket/6896 got applied betternestedsed does not work. This patch fixes this. But note that this will not work with previous versions of rails, so you most probably won't apply it as is. At least you can save time making proper fix. -------------- next part -------------- A non-text attachment was scrubbed... Name: edge_rails_fix.patch Type: text/x-patch Size: 2280 bytes Desc: not available Url : http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071008/4be477eb/attachment.bin From jnicoll at gnexp.com Mon Oct 8 09:53:34 2007 From: jnicoll at gnexp.com (Jeremy Nicoll) Date: Mon, 08 Oct 2007 07:53:34 -0600 Subject: [Betternestedset-talk] Recursive Menu Example In-Reply-To: References: Message-ID: <470A365E.50808@gnexp.com> The title and page are simply example fields. The page is probably a table join like this: class Menu has_one :page end ... and Page has the property of whole_url. You will need to modify the code to suit your layout. This threw me for a long time too since I started using this plugin when I first started to use Ruby and Rails. I suppose the documentation could be a little clearer on the use of these variables. -- Jeremy leon du wrote: > hi all! > > I am now reading the recursive menu example and got some problem with > the code below: > ------------------------------------------------------------------------------------ > > @menus[i] = {:indent => allmenus[i].level, > > :title => allmenus[i].title, > :children_count => allmenus[i].all_children_count, > :url => allmenus[i].page ? allmenus[i].page.whole_url : ''} > > > -------------------------------------------------------------------------- > but in the database section, I dont see the column definition of 'title' and 'page', so is there somthing missed or > > is it my misundstanding? > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071008/6a426360/attachment-0001.html From leondu at gmail.com Mon Oct 8 21:11:24 2007 From: leondu at gmail.com (leon du) Date: Tue, 9 Oct 2007 09:11:24 +0800 Subject: [Betternestedset-talk] Recursive Menu Example In-Reply-To: <470A365E.50808@gnexp.com> References: <470A365E.50808@gnexp.com> Message-ID: oh... thanks I think a more detailed documentation with the whole source code download link could be better for users. 2007/10/8, Jeremy Nicoll : > > The title and page are simply example fields. The page is probably a > table join like this: > > class Menu > has_one :page > end > > ... and Page has the property of whole_url. You will need to modify the > code to suit your layout. This threw me for a long time too since I started > using this plugin when I first started to use Ruby and Rails. I suppose > the documentation could be a little clearer on the use of these variables. > > -- > Jeremy > > > > leon du wrote: > > hi all! > > I am now reading the recursive menu example and got some problem with the > code below: > ------------------------------------------------------------------------------------ > > > @menus[i] = {:indent => allmenus[i].level, > > :title => allmenus[i].title, > :children_count => allmenus[i].all_children_count, > :url => allmenus[i].page ? allmenus[i].page.whole_url : ''} > > > -------------------------------------------------------------------------- > but in the database section, I dont see the column definition of 'title' and 'page', so is there somthing missed or > > is it my misundstanding? > > > ------------------------------ > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071009/a0c72be5/attachment.html From tekin at raid.nu Wed Oct 10 06:04:51 2007 From: tekin at raid.nu (Tekin Suleyman) Date: Wed, 10 Oct 2007 11:04:51 +0100 Subject: [Betternestedset-talk] drag and drop sort Message-ID: <10d401c80b24$ff91c2d0$0500000a@rude10> Just out of curiousity, has anyone done drag and drop ajax sorting with betternestedset? Just trying to establish how straight forward this is before I promise my client the feature.. Tekin Suleyman Raid Associates Ltd 120/122 Grosvenor Street Manchester M1 7HL tel: 0161 272 8310 web: www.raid.nu email: tekin at raid.nu The information contained in this electronic mail may contain confidential or legally privileged information. It is for the intended recipient(s)only. Further communication will signify your consent to this. Should you receive this message in error, please notify the sender by replying to this mail. If you are not the intended recipient, any disclosure, distribution, reproduction, printing or reliance on the contents of this information is strictly prohibited. Whilst all care has been taken, Raid Associates Ltd is not responsible for the integrity of any attachments included within. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071010/9e950a87/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/gif Size: 839 bytes Desc: not available Url : http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071010/9e950a87/attachment.gif -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/gif Size: 163 bytes Desc: not available Url : http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071010/9e950a87/attachment-0001.gif From lists.jc.michel at symetrie.com Wed Oct 10 12:34:39 2007 From: lists.jc.michel at symetrie.com (Jean-Christophe Michel) Date: Wed, 10 Oct 2007 18:34:39 +0200 Subject: [Betternestedset-talk] drag and drop sort In-Reply-To: <10d401c80b24$ff91c2d0$0500000a@rude10> References: <10d401c80b24$ff91c2d0$0500000a@rude10> Message-ID: <2F0764FA-D05C-4219-8652-03B983C00348@symetrie.com> Le 10 oct. 07 ? 12:04, Tekin Suleyman a ?crit : > Just out of curiousity, has anyone done drag and drop ajax sorting > with betternestedset? Just trying to establish how straight forward > this is before I promise my client the feature.. Do you know this: http://dev.oriontransfer.co.nz/SortableTree/ If you can adapt it to nested_set, propose to commit it here ;-) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071010/c70ce935/attachment.html From tiwatson at gmail.com Wed Oct 10 15:00:05 2007 From: tiwatson at gmail.com (Tim Watson) Date: Wed, 10 Oct 2007 15:00:05 -0400 Subject: [Betternestedset-talk] Ordering .roots Message-ID: <959562ce0710101200m66306b6ay2d48067c94faefe5@mail.gmail.com> So I'm calling my nested set model via an association that has an :order attribute to it. This seems to be getting ignored and is using "ORDER BY lft"... but all roots will have a lft of 1, so its really no order. Should I just bypass using .roots and add another association and set the conditions as: parent_id = 0 OR parent_id IS NULL and then the proper :order i need? Or is there another solution I am overlooking? thanks.. -tim -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071010/b48464cb/attachment.html From conradchu at conradchu.com Wed Oct 10 20:06:25 2007 From: conradchu at conradchu.com (Conrad Chu) Date: Wed, 10 Oct 2007 17:06:25 -0700 Subject: [Betternestedset-talk] acts_as_tree migration Message-ID: <6253C6BC-7E40-4B05-BF7A-CCBF66766BC4@conradchu.com> Hi, I currently am using acts_as_tree. I read in an old post (can't recall which one) that it's somehow possible to convert the acts_as_tree by adding the lft and rgt columns and running a "method" to pre-populate them. Is that even possible? If so, can some give me a clue as to how it's done? Thanks! Conrad From dontfall at gmail.com Fri Oct 12 16:43:02 2007 From: dontfall at gmail.com (Krishna Dole) Date: Fri, 12 Oct 2007 13:43:02 -0700 Subject: [Betternestedset-talk] acts_as_tree migration In-Reply-To: <6253C6BC-7E40-4B05-BF7A-CCBF66766BC4@conradchu.com> References: <6253C6BC-7E40-4B05-BF7A-CCBF66766BC4@conradchu.com> Message-ID: <8d64b97d0710121343v3672b48fo2733c15ad3b97b91@mail.gmail.com> Hey Conrad, This should be documented better, but it is actually pretty easy. 1) run a migration to add lft and rgt as integer columns to your table 2) put acts_as_nested_set in your model 3) on script/console run YourModel.find(:first).renumber_full_tree If you have multiple trees in your table, it is a little more complicated. You first need to give each tree scope (add a tree_id column) and then run the above method on a member of each tree. If you want to go back to a plain old tree, all you need to do is run the migration back down and remove acts_as_nested_set from your model. Krishna On 10/10/07, Conrad Chu wrote: > Hi, > > I currently am using acts_as_tree. > > I read in an old post (can't recall which one) that it's somehow > possible to convert the acts_as_tree by adding the lft and rgt > columns and running a "method" to pre-populate them. Is that even > possible? If so, can some give me a clue as to how it's done? > > Thanks! > Conrad > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > From yann.lugrin at sans-savoir.net Mon Oct 15 08:05:25 2007 From: yann.lugrin at sans-savoir.net (Yann Lugrin) Date: Mon, 15 Oct 2007 14:05:25 +0200 Subject: [Betternestedset-talk] Patch for rails 2.0 Message-ID: <200710151405.28146.yann.lugrin@sans-savoir.net> Hello, It is a replacement of Aleksey Kondratenko patch, using 'attr_readonly' instead of overriding of 'readonly_attributes' method, with this change all tests pass. It also modify the test 'test_protected_attributes' to work with Rails 2.0. Yann. -- Yann Lugrin yann.lugrin at sans-savoir.net http://www.sans-savoir.net -------------- next part -------------- A non-text attachment was scrubbed... Name: rails_2_0.patch Type: text/x-diff Size: 3355 bytes Desc: not available Url : http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071015/d8b47ed2/attachment-0002.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part. Url : http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071015/d8b47ed2/attachment-0003.bin From justin at maccarthy.org Tue Oct 16 18:10:23 2007 From: justin at maccarthy.org (Justin MacCarthy) Date: Tue, 16 Oct 2007 23:10:23 +0100 Subject: [Betternestedset-talk] hierarcical menu, caching Message-ID: <9e9015d40710161510g7b8aee5dh7164328910235131@mail.gmail.com> Hi all, I'm doing something you all probably have done 100 times.. I've a cms type system with nested pages eg. http://www.example.com/about_us/mission_statement http://www.example.com/our_products/myshinything http://www.example.com/our_products/myshinything/large My Page model acts_as_nested_set, and has an attribute slug, in the above example we have a page with the slug "mission_statement" with parent page with an attribute "about_us". I need to look up Pages by the full path e.g. Page.find_by_path("about_us/mission_statement"), what is the best way to deal with that ? Can I save the ancestors.slugs / fullpath saved in the database somehow? Or other suggestions.. Hope that makes some sense ??? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071016/6b495da1/attachment.html From jc.michel at symetrie.com Tue Oct 16 18:38:39 2007 From: jc.michel at symetrie.com (Jean-Christophe Michel) Date: Wed, 17 Oct 2007 00:38:39 +0200 Subject: [Betternestedset-talk] hierarcical menu, caching In-Reply-To: <9e9015d40710161510g7b8aee5dh7164328910235131@mail.gmail.com> References: <9e9015d40710161510g7b8aee5dh7164328910235131@mail.gmail.com> Message-ID: HI, Le 17 oct. 07 ? 00:10, Justin MacCarthy a ?crit : > Hi all, I'm doing something you all probably have done 100 times.. > > I've a cms type system with nested pages > > eg. > > http://www.example.com/about_us/mission_statement > http://www.example.com/our_products/myshinything > http://www.example.com/our_products/myshinything/large > > My Page model acts_as_nested_set, and has an attribute slug, in the > above example we have a page with the slug "mission_statement" > with parent page with an attribute "about_us". I need to look up > Pages by the full path e.g. Page.find_by_path("about_us/ > mission_statement"), what is the best way to deal with that ? Can I > save the ancestors.slugs / fullpath saved in the database somehow? > Or other suggestions.. Here is how I deal with paths: in my controller I have a dispatch method that I get called by my route. The idea here is simply to load pages one by one, begining with the first url segment. If a segment is not a good page 'slug' as you call it (it's page.url for me) I default to the portion of the path already processed. Given the fact that most of times url are not more than 3 or 4 'slugs' deep, and that rails + db can cache repetitive similar requests, I think that the overload is worth the simplicity. def dispatch if params[:url].nil? or params[:url].empty? url = [] else url = params[:url].map{|l| l.gsub(/[^a-z0-9_\- \.]/,'')}.delete_if{|l| l.empty?} end @page = Page.root if @page.nil? render :text => "

404

No such page.

", :layout => true, :status => 404 return true end url.each { |u| next_page = Page.find_by_url(u, :conditions => ['parent_id = ?', @page.id]) if next_page.nil? break end @page = next_page } end Hope it helps ! Jean-Christophe Michel -- symetrie.com Better Nested Set for rails: http://opensource.symetrie.com/trac/better_nested_set -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071017/e5fdc80b/attachment.html From chas at munat.com Wed Oct 24 04:51:02 2007 From: chas at munat.com (Charles F. Munat) Date: Wed, 24 Oct 2007 01:51:02 -0700 Subject: [Betternestedset-talk] attributes_with_quotes error Message-ID: <471F0776.20904@munat.com> To work with the latest Edge Rails (8009 as of this writing), this: def attributes_with_quotes(include_primary_key = true) #:nodoc: attributes.inject({}) do |quoted, (name, value)| if column = column_for_attribute(name) quoted[name] = quote_value(value, column) unless !include_primary_key && (column.primary || [acts_as_nested_set_options[:left_column], acts_as_nested_set_options[:right_column]].include?(column.name)) end quoted end end Must be changed to this: def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true) #:nodoc: quoted = attributes.inject({}) do |quoted, (name, value)| if column = column_for_attribute(name) quoted[name] = quote_value(value, column) unless !include_primary_key && (column.primary || [acts_as_nested_set_options[:left_column], acts_as_nested_set_options[:right_column]].include?(column.name)) end quoted end include_readonly_attributes ? quoted : remove_readonly_attributes(quoted) end Sorry for the wrapping. Charles F. Munat Seattle From lesotdudestin at gmail.com Thu Oct 25 14:48:30 2007 From: lesotdudestin at gmail.com (Aimeric PIETERS) Date: Thu, 25 Oct 2007 20:48:30 +0200 Subject: [Betternestedset-talk] before_update problem Message-ID: <18B16D7F-659C-4E25-B54A-15DB0FD63BA7@gmail.com> Hi , I relaunch the question about before_update. Actually, I develop, with other people, a rails application and I use the plugin BetterNestedSet. But we can't use the callback before_update because of overwriting of method update by the plugin. In addition, the before_create and before_destroy method are defined in the plugins, so the user can't define them. Before trying to correct these problems, we would like know if you have solutions or if you will make solutions in a near future. By example, we had thought to use class methods before_create and before_destroy like that: before_create {...}, instead of overwrite them. We would like contribute to the plugin development and, for example, help to make solutions of these problems. Finally, we create a non-recursive method to delete a node of a tree, move its children and renumber node's left and right column. So, we would like give this method to the plugin project. Thanks for you help and your understanding. Sincerely yours, -- Aimeric PIETERS Epita 2009 lesotdudestin at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071025/b47b2a35/attachment.html From raasdnil at gmail.com Fri Oct 26 07:59:09 2007 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Fri, 26 Oct 2007 21:59:09 +1000 Subject: [Betternestedset-talk] drag and drop sort In-Reply-To: <2F0764FA-D05C-4219-8652-03B983C00348@symetrie.com> References: <10d401c80b24$ff91c2d0$0500000a@rude10> <2F0764FA-D05C-4219-8652-03B983C00348@symetrie.com> Message-ID: <57a815bf0710260459y7c5bacfdwc36655a492f39d3b@mail.gmail.com> I was just attacking this in an app today.... First step was finding something that would be able to move a page left or right within it's siblings (ie, not change level yet) I made this but for the life of me can not figure out why it is not working: def move_higher list = self.self_and_siblings index = list.rindex(self) self.move_to_left_of list[index - 1] if index > 0 self.save! end Anyone have any insight? I have been looking at it too long. Basically, you use this on an instance of page. Like page.move_higher. Idea is to move it up if it is not the first child and shift all others down one. Regards Mikel On 10/11/07, Jean-Christophe Michel wrote: > > > Le 10 oct. 07 ? 12:04, Tekin Suleyman a ?crit : > > Just out of curiousity, has anyone done drag and drop ajax sorting with > betternestedset? Just trying to establish how straight forward this is > before I promise my client the feature.. > > > Do you know this: > http://dev.oriontransfer.co.nz/SortableTree/ > > If you can adapt it to nested_set, propose to commit it here ;-) > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20071026/a6e170c1/attachment.html