Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 3 - How to Dynamically Duplicate Record and Submit Multiple Records on Single Form
    primarykey
    data
    text
    <p>I have an INVOICE form. To eliminate tons of typing, users need to enter invoice attributes, then click a button to copy the first record, change a couple attributes, then save all the records at once. Excel style. Help?</p> <pre><code>&lt;% form_for @invoice, :html =&gt; { :multipart =&gt; true } do |f| %&gt; &lt;%= f.error_messages %&gt; &lt;table class="ExcelTable2007"&gt; &lt;tr&gt; &lt;th class="heading"&gt;PO #&lt;font color="red"&gt; *&lt;/font&gt;&lt;/th&gt; &lt;th class="heading"&gt;Invoice #&lt;/th&gt; &lt;th class="heading"&gt;"Bill To" is Correct&lt;/th&gt; &lt;th class="heading"&gt;Invoice Date&lt;/th&gt; &lt;th class="heading"&gt;Date Received&lt;/th&gt; &lt;th class="heading"&gt;AP Clerk Note&lt;/th&gt; &lt;th class="heading"&gt;Division&lt;/th&gt; &lt;th class="heading"&gt;GR Approver&lt;/th&gt; &lt;th class="heading"&gt;GR Alternate Approver&lt;/th&gt; &lt;th class="heading"&gt;Invoice Attachment&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="heading"&gt;&lt;%= f.text_field :po_number, :size =&gt; 10 %&gt;&lt;/td&gt; &lt;td class="heading"&gt;&lt;%= f.text_field :invoice_number, :size =&gt; 10 %&gt;&lt;/td&gt; &lt;td class="heading"&gt;&lt;%= f.check_box :bill_to_address %&gt;&lt;/td&gt; &lt;td class="heading"&gt;&lt;%= f.calendar_date_select "invoice_date", :time =&gt; false, :size =&gt; 12 %&gt;&lt;/td&gt; &lt;td class="heading"&gt;&lt;%= f.calendar_date_select "date_received", :time =&gt; false, :size =&gt; 12 %&gt;&lt;/td&gt; &lt;td class="heading"&gt;&lt;%= f.text_field :clerk_note %&gt;&lt;/td&gt; &lt;td class="heading"&gt;&lt;%= f.collection_select :division_id, Division.active.order(:division), :id, :division, :include_blank =&gt; true %&gt;&lt;/td&gt; &lt;td class="heading"&gt;&lt;%= f.collection_select :approver_username, Aduser.order(:last_name, :first_name), :username, :fullname, :include_blank =&gt; true %&gt;&lt;/td&gt; &lt;td class="heading"&gt;&lt;%= f.collection_select :alternate_approver_username, Aduser.order(:last_name, :first_name), :username, :fullname, :include_blank =&gt; true %&gt;&lt;/td&gt; &lt;td class="heading"&gt;&lt;%= f.file_field :attachment %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/p&gt; &lt;/table&gt; &amp;emsp;&amp;emsp;&amp;emsp;&amp;emsp;&lt;%= link_to "Add Invoice", clone_invoice_url(@invoice) %&gt; &lt;br&gt; &lt;br&gt; &lt;div class="actions"&gt; &lt;%= f.submit "Submit" %&gt; &lt;/div&gt; &lt;/p&gt; &lt;% end %&gt; </code></pre> <p>I tried the following, but receive an invalid authenticity token:</p> <pre><code>def clone_invoice @invoice = Invoice.find(params[:id]).dup @invoice.save end </code></pre> <p>Can anyone help me? Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload