Ben
2008-Jun-08 07:38 UTC
[Betternestedset-talk] Question about getting roots for a given scope
Hi All, I have just found this nested set plugin today and so far it is fitting my needs very well. I have one question. My application has a need for a nested set "per user" on the system. I would like to split these trees using a scope. so i have in my Task model - acts_as_nested_set :scope=>:user This all seems to work correctly. My question is, how can i get the roots for this user? To get the roots for the whole table I am using Task.roots() Is there a way i can get the roots for a given user? Thanks, ~Ben
Stephen Schor
2008-Jun-08 15:07 UTC
[Betternestedset-talk] Question about getting roots for a given scope
Hi Ben, If your task table has a user_id in it can you could roll your own getter in the User class like... has_many :root_tasks, :class => ''Task'',:conditions => ''parent_id IS NULL'' On Sun, Jun 8, 2008 at 3:38 AM, Ben <ben at fearofpudding.com> wrote:> Hi All, > > I have just found this nested set plugin today and so far it is fitting my > needs very well. > I have one question. My application has a need for a nested set "per user" > on the system. I would like to split these trees using a scope. > > so i have in my Task model - acts_as_nested_set :scope=>:user > > This all seems to work correctly. My question is, how can i get the roots > for this user? To get the roots for the whole table I am using Task.roots() > > Is there a way i can get the roots for a given user? > > Thanks, > ~Ben > _______________________________________________ > 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/20080608/9029315a/attachment.html>
ben at fearofpudding.com
2008-Jun-10 03:06 UTC
[Betternestedset-talk] Question about getting roots for a given scope
Thanks - that method works a treat. ~Ben> Hi Ben, > > If your task table has a user_id in it can you could roll your own getter > in > the User class like... > > has_many :root_tasks, :class => ''Task'',:conditions => ''parent_id IS NULL'' > > On Sun, Jun 8, 2008 at 3:38 AM, Ben <ben at fearofpudding.com> wrote: > >> Hi All, >> >> I have just found this nested set plugin today and so far it is fitting >> my >> needs very well. >> I have one question. My application has a need for a nested set "per >> user" >> on the system. I would like to split these trees using a scope. >> >> so i have in my Task model - acts_as_nested_set :scope=>:user >> >> This all seems to work correctly. My question is, how can i get the >> roots >> for this user? To get the roots for the whole table I am using >> Task.roots() >> >> Is there a way i can get the roots for a given user? >> >> Thanks, >> ~Ben >> _______________________________________________ >> 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 >