<div id="product-list"> <h1>Listing orders</h1> <table> <tr> <th>Name</th> <th>Address</th> <th>Email</th> <th>Pay type</th> <th>Total value</th> </tr> <% for order in @orders %> <tr class="<%= cycle('list-line-odd', 'list-line-even') %>"> <td><%=h order.name %></td> <td><%=h order.address %></td> <td><%=h order.email %></td> <td><%=h order.pay_type %></td> <td><%= number_to_currency (order.line_items.inject(0) {|sum,item| sum + item.total_price}), :unit => "£" %></td> <td><%= link_to 'Show', order %></td> <td><%= link_to 'Edit', edit_order_path(order) %></td> <td><%= link_to 'Destroy', order, :confirm => 'Are you sure?', :method => :delete %></td> </tr> <% for li in order.line_items %> <tr class="<%= current_cycle %>"> <td> </td> <td colspan="7"><i><%= li.quantity%> × <%= h li.product.title %> = <%= number_to_currency li.total_price, :unit => "£" %> </i></td> </tr> <% end %> <% end %> </table> <br /> <%= link_to 'New order', new_order_path %> </div>