title: sum of deep nested form attributes
body: <p>rails 4 + cocoon </p>
  
  <p>A little background: </p>
  
  <p><code>orders has_many order_products</code>
  <code>order_products has_many product_sizes</code></p>
  
  <p>In an after_save call I would like to get the total quantity of all the products. I have a database column named <code>total_qty</code> in the <code>order_product</code> model. So in this pic the total would be 37.</p>
  
  <p><a href="https://i.stack.imgur.com/Msz3j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Msz3j.png" alt="Screen shot"></a></p>
  
  <p>order form</p>
  
  <pre><code>= f.simple_fields_for :order_products do |order_product|
      = render 'order_product_fields', :f =&gt; order_product
        = link_to_add_association 'Add Product', f, :order_products
  </code></pre>
  
  <p>order_product_fields</p>
  
  <pre><code>= f.simple_fields_for :product_sizes do |product_size|
        = render 'product_size_fields', :f =&gt; product_size
          = link_to_add_association 'Add Size', f, :product_sizes
  </code></pre>
  
  <p>product_size_fields</p>
  
  <pre><code>&lt;div class="row nested-fields"&gt;
   = f.input :size_name, :collection =&gt; Order::SIZES, label: false, include_blank: false
   = f.input :qty, label: false, class: "&lt;%= product_sizes.index %&gt;"
   = link_to_remove_association f, class: 'btn btn-danger' do
    .glyphicon.glyphicon-remove
  &lt;/div&gt;
  </code></pre>