[Rails] get data from has_and_belongs_to_many + has_many

2010-05-20 Thread Ale Ds
I have 3 models, A, B and C and the classic 3 relations: 1) A --- has_and_belongs_to_many --- B 2) B has_many C B - c1 - c2 - c3 ... 3) C belong_to B C - a1 Question: How can I get C entries in relationship to an A entry ? in other words, I have a = A.find id and I want C I have

Re: [Rails] get data from has_and_belongs_to_many + has_many

2010-05-20 Thread Michael Pavling
On 20 May 2010 15:00, Ale Ds li...@ruby-forum.com wrote: Question: How can I get C entries in relationship to an A entry ? in other words, I have a = A.find id and I want C You need to iterate over a's bs [1] collection, and return the related cs. Then probably only return uniq c records