Forum: Ruby on Rails newbie question

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.
Harm de Laat (Guest)
on 2005-12-23 18:47
(Received via mailing list)
Hi all,

I'm following the shop example in 'Agile Web D. with Rails'.

I would like to extend the checkout screen, in such a way people can
the number of items they have selected in there cart.

In my controller I have:

  def checkout
      @cart = find_cart
      @items = @cart.items
      if @items.empty?
          redirect_to_index("There's nothing in your cart!")
          @order =
          @address =

I also created the following checkout.rhtml file:

<% @page_title = "Checkout" -%>

<%= error_messages_for(:order) %>

<%= start_form_tag(:action => "update_order") %>

<%= render(:partial => 'orderitem', :collection => @items) %>

<%= submit_tag "Update" %>

<%= end_form_tag %>

Finally I created the following partial:

<% product = orderitem.product %>

    <td><%= check_box 'orderitem', 'delete', 'index' =>
    <td><%= text_field 'orderitem', 'quantity', 'value' =>
orderitem.quantity, 'index' => orderitem_counter, :size => 4 %></td>
    <td><%= product.brand %> <%= product.title %></td>

Now when the user submits the form, I would like to read the quantity
each line_item and update my cart accordingly. Also, if the checkbox is
checked I would like to delete the line_item from the cart.

I have no clue how to do this in my controller....

Can you give me a hint?


Harm de Laat
This topic is locked and can not be replied to.