Greg Willits wrote in post #955558: > Colin Law wrote in post #955556: >> On 19 October 2010 21:06, Greg Willits <[email protected]> wrote: >>> Aaa has_many Bbb and Bbb has_many Ccc. There is no :through involved. >>> Ccc table does not have a FK back to Aaa. (Legacy schema.) >> >> I do not understand what you mean by 'there is no through involved'. >> In the situation described you may say >> Aaa :has_many :cccs, :through => :bbbs >> then you may use aaa.cccs > > My existing schema does not match the example laid out here: > http://guides.rubyonrails.org/association_basics.html#the-has_many-through-association
That example contains some irrelevant key fields, aimed more at a habtm-type setup than what you're doing. What you're doing is described exactly in the last paragraph of the section you referred to, starting at 'The has_many :through association is also useful for setting up “shortcuts”....'. The example there matches your use case exactly: Document is A, Section is B, and Paragraph is C. > > I do not have one table capable of pointing in parallel to two tables as > diagramed. No. You don't need one. The A *class* points to 2 tables, the "as" table does not have to. > The schema I am working with is strictly A->B->C and not > A->B and A->C. Exactly as given in the part of the guide I pointed to. > > But, I'll give it a try as you guys seem to think it should still work. Indeed it should. You're describing a classic use case for has_many :through. > > -- gw Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- 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 [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.

