AWDwR Partial Template Question

The following code uses partial template. My question is: What happened to the looping of cart items?

add_to_cart.rhtml

<div class="cart-title">Your Cart</div> <table> <% for cart_item in @cart.items %> <tr> <td><%= cart_item.quantity %>&times;</td> <td><%= h(cart_item.title) %></td> <td class="item-price"><%= number_to_currency(cart_item.price) %></td> </tr> <% end %> <tr class="total-line"> <td colspan="2">Total</td> <td class="total-cell"><%= number_to_currency(@cart.total_price) %></td> </tr> </table> <%= button_to "Empty cart", :action => :empty_cart %>

Refactored add_to_cart.rhtml

<div class="cart-title">Your Cart</div> <table> <%= render(:partial => "cart_item", :collection => @cart.items) %> <tr class="total-line"> <td colspan="2">Total</td> <td class="total-cell"><%= number_to_currency(@cart.total_price) %></td> </tr> </table> <%= button_to "Empty cart", :action => :empty_cart %>

_cart_item.rhtml

<tr> <td><%= cart_item.quantity %>&times;</td> <td><%= h(cart_item.title) %></td> <td class="item-price"><%= number_to_currency(cart_item.price) %></td> </tr>

The :collection parameter causes render(0 to invoke the template once for each item in the collection.

Dave