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.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to