+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
- <title>LineItems: <%= controller.action_name %></title>
- <%= stylesheet_link_tag 'scaffold' %>
-</head>
-<body>
-
-<p style="color: green"><%= flash[:notice] %></p>
-
-<%= yield %>
-
-</body>
-</html>
<th>Address</th>
<th>Email</th>
<th>Pay type</th>
+ <th>Total value</th>
</tr>
<% for order in @orders %>
<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>
+ <td> </td>
+ <td colspan="3"><i><%= li.quantity%> ×
+ <%= h li.product.title %> =
+ <%= number_to_currency li.total_price, :unit => "£" %>
+ </i></td>
+ </tr>
+ <% end %>
+
<% end %>
</table>