belongs_to :through definitely is not necessary just like
has_many :through is not necessary and wasn't even included in earlier
releases of Rails.  With Rails 3, creating scopes that are lazily
loaded provides a lot of functionality that would be nice to extend to
the belongs_to :through relationship.

On Nov 5, 2:18 pm, Tim Shaffer <[email protected]> wrote:
> On Nov 5, 1:13 pm, TomRossi7 <[email protected]> wrote:
>
> > Why is belongs_to :through not an option with Rails?  I'm sure there
> > is something I'm missing!  I find myself wanting it more now with lazy
> > loading in Rails 3.
>
> > project belongs_to client
>
> > task belongs_to project
> > task belongs_to client :through project
>
> belongs_to :through is not necessary, which is why it's not an option.
>
> So you are saying your tables would look like this:
>
> TASK
> name
> project_id
>
> PROJECT
> name
> client_id
>
> CLIENT
> name
>
> And you would like to be able to find all tasks for a given client?
>
> In that case, you would say client has_many :tasks, :through
> => :project
>
> Then instead of "Task.joins(:project => :client)" You can do
> "Client.find_by_name('asdf').tasks"

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to