I am trying to run a query of an orders table to find an order number based on a user given id and then give a total for the order based on the quantity * price. I have the following
@ordertotals = Orderlines.where(id: @orderinfo.id).sum("quantity * price")
which would place the total in to a new object for each one. I am then trying to display all of the values found to do that I have
<table border=1>
<tr>
<td>Order Number</td>
<td>Order Date</td>
<td>Cost of Order</td>
</tr>
<% # for each customer who has this sales rep
# display each customer in a row
for @custdata in @orderinfo %>
<tr>
<td><%=@orderinfo.id%></td>
<td><%=@orderinfo.order_date%></td>
<% for @orderinfo in @ordertotals %>
<td><%=@ordertotals%></td>
</tr>
<% end %>
<% end %>
</table>
Which would loop through the @orderinfo first to display the id and order date then loop through the @ordertotals to display each total. However when I run this I get compiler errors on the
@ordertotals = Orderlines.where(id: @orderinfo.id).sum("quantity * price")
line, could anyone tell me what I am doing wrong here and if the way I have printing setup would work?
EDIT: Sorry forgot to add the errors here they are
compile error
/rails1/app/views/ordersdisplay.html.erb:22: syntax error, unexpected ':', expecting ')'
...rtotals = Orderlines.where(id: @orderinfo.id).sum("quantity ...
^
/rails1/app/views/ordersdisplay.html.erb:22: syntax error, unexpected ')', expecting kEND
...lines.where(id: @orderinfo.id).sum("quantity * price")
^
/rails1/app/views/ordersdisplay.html.erb:55: syntax error, unexpected kENSURE, expecting $end