title: Rails nested_form adding items to table rows
body: <p>My goal is to use the nested_form gem: <a href="https://github.com/ryanb/nested_form" rel="noreferrer">https://github.com/ryanb/nested_form</a>
    but instead of creating just a new set of labels and fields every time you add an object, I wanted to insert a row into an existing table.  </p>
  
  <pre><code>= nested_form_for @transaction do |f|
  %h3 Line Items 
  %table
    %tr
      %th Branch
      %th Department
      %th Invoice #
      %th Amount
      %th Transaction Type
      %th Deposit (y/n)
      %th
  
    = f.fields_for :line_items do |line_item|
      %tr
        %td 
          = line_item.text_field :location_id
        %td 
          = line_item.text_field :department_id
        %td 
          = line_item.text_field :invoice_num
        %td 
          = line_item.text_field :amount
        %td 
          = line_item.text_field :transaction_type
        %td 
          = line_item.text_field :deposit
        %td= line_item.link_to_remove "Remove"
      %p= f.link_to_add "Add", :line_items
  </code></pre>
  
  <p>The .link_to_add button just creates a bunch of fields in the first row, first td.</p>
  
  <pre><code>&lt;h3&gt;Line Items&lt;/h3&gt;
  &lt;table&gt;
    &lt;tr&gt;
      &lt;th&gt;Branch&lt;/th&gt;
      &lt;th&gt;Department&lt;/th&gt;
      &lt;th&gt;Invoice #&lt;/th&gt;
      &lt;th&gt;Amount&lt;/th&gt;
      &lt;th&gt;Transaction Type&lt;/th&gt;
      &lt;th&gt;Deposit (y/n)&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
    &lt;/tr&gt;
    &lt;div class="fields"&gt;&lt;tr&gt;
      &lt;td&gt;
        &lt;input id="transaction_line_items_attributes_0_location_id" name="transaction[line_items_attributes][0][location_id]" size="30" type="text" /&gt;
      &lt;/td&gt;
      &lt;td&gt;
        &lt;input id="transaction_line_items_attributes_0_department_id" name="transaction[line_items_attributes][0][department_id]" size="30" type="text" /&gt;
      &lt;/td&gt;
      &lt;td&gt;
        &lt;input id="transaction_line_items_attributes_0_invoice_num" name="transaction[line_items_attributes][0][invoice_num]" size="30" type="text" /&gt;
      &lt;/td&gt;
      &lt;td&gt;
        &lt;input id="transaction_line_items_attributes_0_amount" name="transaction[line_items_attributes][0][amount]" size="30" type="text" /&gt;
      &lt;/td&gt;
      &lt;td&gt;
        &lt;input id="transaction_line_items_attributes_0_transaction_type" name="transaction[line_items_attributes][0][transaction_type]" size="30" type="text" /&gt;
      &lt;/td&gt;
      &lt;td&gt;
        &lt;input id="transaction_line_items_attributes_0_deposit" name="transaction[line_items_attributes][0][deposit]" size="30" type="text" /&gt;
      &lt;/td&gt;
      &lt;td&gt;&lt;input id="transaction_line_items_attributes_0__destroy" name="transaction[line_items_attributes][0][_destroy]" type="hidden" value="false" /&gt;&lt;a href="javascript:void(0)" class="remove_nested_fields" data-association="line_items"&gt;Remove&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;td&gt;&lt;a href="javascript:void(0)" class="add_nested_fields" data-association="line_items"&gt;Add&lt;/a&gt;&lt;/td&gt;
    &lt;/div&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I've tried placing the .link_to_add  in a few places, but it doesn't put them in their own row.</p>
  
  <p>Is there an easy way to go about adding a row of input boxes each time?</p>