> Michael Pavling wrote:
> 
> You need to iterate over a's bs [1] collection, and return the related
> cs. Then probably only return uniq c records (a given c might be
> linked to more than one b...)
> This should give you what you want:
> 
>   cs=[]
>   a.bs.each do |b|
>     cs += b.cs
>   end
>   cs.uniq!
This is the solution that I don't like to use
> 
> and this is the same thing:
>   a.bs.inject {|cs, b| sum + b.cs }.uniq
> 
this looks interesting ! (even if I have to brush up 'inject' :) )
but I am looking for a more simpe solution

thank you,
Alessandro DS


> [1] This is why convention prefers Foo/Bar for example names.... "a,
> b, c" doesn't make for easy or understandable reading.

Yes, I agree with you (the pluralization of A,B,C is unreadable)
-- 
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.

Reply via email to