[Betternestedset-talk] Display whole tree without requestingdbfor each node

Tekin Suleyman tekin at raid.nu
Thu Jul 26 08:40:23 EDT 2007


Why didn't I think of that! I'll give it a try.

-----Original Message-----
From: betternestedset-talk-bounces at rubyforge.org
[mailto:betternestedset-talk-bounces at rubyforge.org] On Behalf Of Mikel
Lindsaar
Sent: 25 July 2007 00:20
To: betternestedset-talk at rubyforge.org
Subject: Re: [Betternestedset-talk] Display whole tree without
requestingdbfor each node


If you have this as an ongoing requirement, a "simple" solution might be
storing the level in the model itself in an after save call back.

It's a bit of a hack, but you can only move the nodes through update
calls anyway... so it might work.  Then you have it automagically as an
instance method.

Regards

Mikel

On 7/25/07, Tekin Suleyman <tekin at raid.nu> wrote:
>
> This is something I've wondered also as it more or less cancels out 
> any speed gain from getting the full set in one query. Does 
> betternestedset provide the hooks to cache the level? Alternatively, 
> the parent_id could theoretically be used to calculate levels from a 
> full set.
>
>
>
> -----Original Message-----
> From: betternestedset-talk-bounces at rubyforge.org
> [mailto:betternestedset-talk-bounces at rubyforge.org] On Behalf Of 
> Jean-Christophe Michel
> Sent: 23 July 2007 22:02
> To: betternestedset-talk at rubyforge.org
> Subject: Re: [Betternestedset-talk] Display whole tree without 
> requesting dbfor each node
>
>
> Hi,
>
> Le 23 juil. 07 à 17:37, Jonas Arklint a écrit :
> > I´m wondering how I display the whole tree without having to request

> > the db each time I use @node.level.
>
> You have to cache the level in db, or simply compute it in code after 
> you read your tree part.
>
> 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
>
> _______________________________________________
> 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



More information about the Betternestedset-talk mailing list