[Betternestedset-talk] Question about getting roots for a given scope

ben at fearofpudding.com ben at fearofpudding.com
Mon Jun 9 23:06:35 EDT 2008


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
>




More information about the Betternestedset-talk mailing list