title: How to assign a value to a accepts_nested_attributes_for model
body: <p>This is a follow-up to this question <a href="https://stackoverflow.com/questions/9404064/wheres-the-appropriate-place-to-handle-writing-the-current-user-id-to-an-object">where&#39;s the appropriate place to handle writing the current_user.id to an object</a> I have the following model. An item which has_many assets. I'm am <code>using accepts_nested_attributes_for :assets</code> in the item.</p>
  
  <p>I'd like to assign the current_user.id value to each asset. Normally I just do <code>@item.update_attributes(params[:item])</code> to save it. Is there a simple one line way of setting the user_id for each asset in this scenario? </p>
  
  <p>Looking in dev log, I see the value here:  </p>
  
  <pre><code> item[assets_attributes][10][asset]
  </code></pre>
  
  <p>Should I just iterate through all of these and set a user_id value?</p>
  
  <p>thx</p>
  
  <p>here's some more of the html (items -> menu_item; had left out above to simplify). The proposed controller sol'n below does not seem to work. I'm fine with doing at the level of controller. Any help appreciated. </p>
  
  <pre><code> &lt;div class='image-row'&gt;
      &lt;input id="menu_item_assets_attributes_18_asset" name="menu_item[assets_attributes][18][asset]" type="file" /&gt;
      &lt;input id="menu_item_assets_attributes_18_description" name="menu_item[assets_attributes][18][description]" size="30" type="text" /&gt;
      &lt;/div&gt;
    &lt;div class='image-row'&gt;
      &lt;input id="menu_item_assets_attributes_19_asset" name="menu_item[assets_attributes][19][asset]" type="file" /&gt;
      &lt;input id="menu_item_assets_attributes_19_description" name="menu_item[assets_attributes][19][description]" size="30" type="text" /&gt;
     &lt;/div&gt;
   &lt;div class='image-row'&gt;
       &lt;a href="/images/371/5ea19b9cfa534f1c1f5457ebb149d4259a662f88_huntbch_original.jpg?1329917713"&gt;&lt;img alt="D5cc413a1748fb43b0baa2e32e29b10ac2efda10_huntbch_thumb" src="/images/371/d5cc413a1748fb43b0baa2e32e29b10ac2efda10_huntbch_thumb.jpg?1329917713" /&gt;&lt;/a&gt;
  &lt;div class='img-row-description'&gt;
       &lt;label for="menu_item_assets_attributes_20_description"&gt;Description&lt;/label&gt;
       &lt;input id="menu_item_assets_attributes_20_description" name="menu_item[assets_attributes][20][description]" size="60" type="text" value="here is my comment" /&gt;
       &lt;label for="menu_item_assets_attributes_20_destroy"&gt;Destroy&lt;/label&gt;
       &lt;input name="menu_item[assets_attributes][20][_destroy]" type="hidden" value="0" /&gt;&lt;input id="menu_item_assets_attributes_20__destroy" name="menu_item[assets_attributes][20][_destroy]" type="checkbox" value="1" /&gt;
    &lt;/div&gt;
  </code></pre>