Hi all!  I was hoping someone could help me with another issue...

I have an INVOICE form.  Users would like to create multiple records at the 
same time.  In addition, they would like to copy the first record's 
attributes for the next record, so they only have to change a few fields.  
Less typing.  MS Excel style.

I've seen the Railscast for adding multiple records through nested 
attributes, but I'm using a single model, so I don't know how that 
applies.  I do not want to break out my flat invoice table if I can avoid 
it.

I've tried the following, but when I click on "Add Invoice", I get an 
error: "Couldn't find an invoice without an ID".  

_form.html.erb:

<% form_for @invoice, :html => { :multipart => true } do |f| %>
  
<table class="ExcelTable2007">
     <tr>       
       <th class="heading">PO #<font color="red"> *</font></th>
       <th class="heading">Invoice #<font color="red"> *</font></th>
       <th class="heading">"Bill To" is Correct</th>
       <th class="heading">Invoice Date<font color="red"> *</font></th>
       <th class="heading">Date Received<font color="red"> *</font></th>
       <th class="heading">AP Clerk Note<font color="red"> *</font></th>
       <th class="heading">Division<font color="red"> *</font></th>
       <th class="heading">GR Approver<font color="red"> *</font></th>
       <th class="heading">Invoice Attachment<font color="red"> 
*</font></th>
     </tr>  
     <tr>       
       <td class="heading"><%= f.text_field :po_number, :size => 10 %></td>
       <td class="heading"><%= f.text_field :invoice_number, :size => 10 
%></td>
       <td class="heading"><%= f.check_box :bill_to_address %></td>
       <td class="heading"><%= f.calendar_date_select "invoice_date", :time 
=> false, :size => 12 %></td>
       <td class="heading"><%= f.calendar_date_select "date_received", 
:time => false, :size => 12 %></td>
       <td class="heading"><%= f.text_field :clerk_note %></td>
       <td class="heading"><%= f.collection_select :division_id, 
Division.active.order(:division), :id, :division, :include_blank => true 
%></td>
       <td class="heading"><%= f.collection_select :approver_username, 
Aduser.order(:last_name, :first_name), :username, :fullname, :include_blank 
=> true %></td>
       <td class="heading"><%= f.file_field :attachment %></td>
      </tr>
    </p>
</table>
&emsp;&emsp;&emsp;&emsp;<%= link_to "Add Invoice", 
clone_invoice_url(@invoice) %>
  <br>
  <br>
  
  <div class="actions">
    <%= f.submit "Submit" %>
  </div>
  </p>
<% end %>

---------------------------------------------

invoices_controller:

def clone_invoice
  @invoice = Invoice.find(params[:id])
  @new_invoice = @invoice.dup
end

-- 
-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
--- 
You received this message because you are subscribed to the Google Groups "SD 
Ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to