[Betternestedset-talk] root with scope?
Cynthia Kiser
cnk at caltech.edu
Mon Apr 7 21:18:52 EDT 2008
Quoting Peter Schrammel <peter.schrammel at gmx.de>:
> 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 think you need to specify 2 things - what the user id is, and that
you want the root of that set. In the model where I similarly want the
root of someones things, I do the following:
def self.find_persons_base_page(person_id)
return PersonalPage.find_by_person_id_and_parent_id(person_id, nil)
end
--
Cynthia Kiser
More information about the Betternestedset-talk
mailing list