title: group and count by nested association in rails
body: <p>So I have the following associations (An Order comes from a Catch that is of a fish).</p>
  
  <p>I want to, group a set of orders by the fish they are of, and then sum the quantity ordered attribute within order for each group.</p>
  
  <p>I can do it for each catch with </p>
  
  <p>Order.all.group(:catch_id).sum(:qty_ordered)</p>
  
  <p>but not for the fish.</p>
  
  <pre><code>class Order &lt; ActiveRecord::Base
      belongs_to :user
      belongs_to :catch
  end
  
  class Catch &lt; ActiveRecord::Base
      has_many :orders
      belongs_to :fish
  end
  
  class Fish &lt; ActiveRecord::Base
      has_many :catches
  end
  </code></pre>
  
  <p>Any tips?</p>