I have looked at examples for this. I found a similar example in the
Agile Web Dev… book but that didn’t help. Here’s what i am trying to
do.
A Cart has many line items. On the Display Cart page, I want to provide
the user the option to update quantities.
Here’s the rhtml code:
<%= start_form_tag :action => ‘update_cart’ %>
<% for @item in @items %>
<%= @item.product.title %>
<%= text_field “item[]”,‘quantity’ %>
<%= number_to_currency(@item.unit_price) %>
$<%= @item.quantity * @item.unit_price %>
<%= link_to ‘Remove item’, {:action => ‘remove_from_cart’, :id =>
@item.product} %>
<% end %>
Total
$ <%= @cart.total_price %>
<%= submit_tag ‘Update Cart’ %>
<%= end_form_tag %>
In the Page->View source I find that all text boxes have the name
item[quantity]. I expected the names to be item[0][quantity],
item[1][quantity] and so on.
And instead of passing all the rows as params, only the first row (i.e.
first line item) is being passed to the update_cart function.
I’ve spent 3 days on this. Please help !!