Forum: Ruby on Rails Dynamic fields creation and accessing data

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Naroor R. (Guest)
on 2005-12-20 08:06
Hi friends ,
   I was trying this code and finding some errors.I am trying this to
implement dynamic creation of invoice items in invoices using AJAX
.Please go thru .

 I added a partial ::
<% @invoiceitem = invoiceitem -%>
 <%= text_field 'invoiceitem', 'item_price', 'index' =>
 invoiceitem_counter %>
 <%= text_field 'invoiceitem', 'item_qty', 'index' =>
Where are we initialising the counter? Please tell how is the first line
working .

In the rhtml file I have added  :

    <%= form_remote_tag(:update => "my_list",
                       :url => { :action => :add_new_item },
                       :position => "bottom" ) %>

            <%= submit_tag "Add New Item" %>
       <%= end_form_tag %>
   <form action="/ajax/save_items" method="post">
    <ul id="my_list">
      <li>Original item... please add more!</li>

    <%= submit_tag 'Update' %>
I have added like this for creating a dynamic generation of text boxes
using ajax.

And in the controller class ,

  def add_new_item

   render(:partial => 'invoiceitems', :collection => @invoice_items)

  def save_items

	 @items = []
	params[:invoiceitem].each do |key, item|
		@items =

Please help my in implementing this requirement .

Thanks and regards,
Naroor R..
This topic is locked and can not be replied to.