[Betternestedset-talk] root with scope?
Stephen Schor
beholdthepanda at gmail.com
Fri Apr 4 15:16:43 EDT 2008
Hi Peter,
My table contains multiple roots using scope. I've never really called .root
on the class.
I've sometimes wanted to find the root of an instance by calling
my_instance.root to return
the top-most ancestor or my_instance.
Also - looking at the comments of .root in the SingletonMethods module -
there's this info...
# Returns the single root for the class (or just the first root, if there
are several).
# Deprecation note: the original acts_as_nested_set allowed roots to have
parent_id = 0,
# so we currently do the same. This silliness will not be tolerated in
future versions, however.
I hope this is helpful to you.
-Stephen
On Fri, Apr 4, 2008 at 1:31 PM, Peter Schrammel <peter.schrammel at gmx.de>
wrote:
> Hi,
>
> I'm trying to get the root of a scoped set but all I get is:
>
> r=Album.root(:user_id=>4)
> ArgumentError: Unknown key(s): user_id
>
> My code is quite simple:
>
> class Album < ActiveRecord::Base
> acts_as_nested_set :scope => :user
> end
>
> The db has a user_id column and the columns BNS needs (parent_id,lft,rgt).
>
> I'm useing the svn trunk of today. Any tips (I hope the bug is between
> my ears)?
>
>
> Thanks,
>
> Peter
> _______________________________________________
> 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/20080404/4825d281/attachment.html
More information about the Betternestedset-talk
mailing list