title: Rails 3.1 - :fields_for, :child_index not incrementing
body: <p>I have a nested attributes form with the following and am just learning how to use nested attributes. One problem I'm having is that the child_index values is not incrementing up. I'm getting  3 fields based upon the build in the controller but they all have 0 or 1 depending on what number is set to. </p>
  
  <p>Any ideas on how to get this to increment? </p>
  
  <pre><code># in controller: 3.times {@item.assets.build}
  &lt;% number = 1 %&gt;
  &lt;div id='files'&gt;
    &lt;%= f.fields_for :assets, :child_index =&gt; number do |asset| %&gt;
      &lt;p&gt;
      number:&lt;%= number %&gt;&lt;br /&gt;
      &lt;%=asset.label :asset, "File ##{number += 1}" %&gt;
      &lt;%= asset.file_field :asset %&gt;
     &lt;/p&gt;
  &lt;% end %&gt;
  &lt;/div&gt;
  &lt;%= f.submit %&gt;
  </code></pre>
  
  <p>edit:
  so all of them in html would have the form like:</p>
  
  <pre><code>item[assets_attributes][0][asset]
  </code></pre>
  
  <p>rather than the desired:</p>
  
  <pre><code>menu_item[assets_attributes][0][asset]
  menu_item[assets_attributes][1][asset] 
  menu_item[assets_attributes][2][asset]
  </code></pre>
  
  <p>edit #2:
  so looking through the source code, I see the following and am wondering if rails is supposed to be doing some auto-swapping and possibly this isn't happening;</p>
  
  <pre><code>&lt;input id="item_assets_attributes_0_asset" name="item[assets_attributes][0][asset]" type="file" /&gt;
  &lt;input id="item_assets_attributes_0_id" name="item[assets_attributes][0][id]" type="hidden" value="1" /&gt;
  </code></pre>