Let’s assume that I am trying to build an application where the user can
enter invoice.
In the app the user can add lines items. Each line item has decription,
date, rate and hours.
When the invoice screen comes up the first time I have one blank row for
the
line items.
<tr>
<th>Description</th>
<th>Date</th>
<th>Hours </th>
<th>Rate </th>
</tr>
<tr>
<td><%= text_field 'lineitem','desc-1' %></td>
<td><%= text_field 'lineitem','date-1' %></td>
<td><%= text_field 'lineitem','hours-1'%></td>
<td><%= text_field 'lineitem','rate-1' ></td>
</tr>
Now the user wants to add another line. Using ajax I create one more
row.
<tr>
<td><%= text_field 'lineitem','desc-2' %></td>
<td><%= text_field 'lineitem','date-2' %></td>
<td><%= text_field 'lineitem','hours-2'%></td>
<td><%= text_field 'lineitem','rate-2' ></td>
</tr>
But the problem is that the model Lineitem has following attributes:
desc,date,hours and rate.
What is the best way to handle such cases. I don’t want to have items
like
desc-1 and rate-2.
Thanks.