I am working on an app and I need the following behavior :
A :has_many B
A :has_many C :though B
C :has_many B
C has_many A :through B
My goal is to find all the A objects that are related to a given ‘a’
object, based on the fact that they have some Cs in common;
Here is how I’d do it :
related = 
a.cs.each do |c|
related << c.as
I am pretty sure this is not the good solutions : it makes a lot of
request, and there is just now way to “Order” the related objects by the
number of cs they have in common with a!
Anyone has a better idea on how to do it?