help my with next question:
I have table brands and table products ( has_many - belongs_to association )
in table products i have field "Rank".
And i want to display top5 brands whose total rank of its products - greatest
I try to:
Brand.joins(:products).order('products.rank DESC').limit(10).uniq! But that incorrect - thats not a sum of products.rank...
How to relize with sum of product ranks