I think the problem is that you`re trying to call a tasks method from an
Array Class, you should do that for a Tab class, so try this, i didn`t
tested but i think it can help:

User.find(particular_user_id).tabs.collect {|c| c.tasks}.flatten

Good luck,

Fernando Santos


2010/12/28 Marnen Laibow-Koser <li...@ruby-forum.com>

> bourne wrote in post #971069:
> > Given the following relations (see bottom of post)
> > n:m   Users - Tabs  (has_many has_many; trough sharedtabs)
>
> That should probably be :shared_tabs.
>
> > 1:n    Tabs - Tasks  (has_many and belongs_to)
> >
> > I am stuck in the queries:
> > @test = User.find(2).tabs.find(3).tasks   <-- all tasks in tab #3 of
> > user 2,
> > works
> >
> > I want to query all tasks that belong to all tabs of a particular user
> > @test = User.find(2).tabs.tasks                <-- undefined method
> > tasks
> > @test = User.find(2).tabs.find(:all).tasks  <-- undefined method tasks
>
> Of course!  Tasks is only defined for individual Tab objects, not for an
> array of them.
>
> What you need to do is create an additional :through relation, so that
> User has_many :tasks, :through => :tabs .  You may have to use the
> nested_has_many_through plugin.
>
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> mar...@marnen.org
>
> Sent from my iPhone
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to