<% for product in @order.line_items -%>
<% total_price += (product.price * product.quantity) -%>
<tr>
<td><strong><%= product.item.description%></strong></td>
<td><%= product.item.category.category_name%></td>
<td><%= product.quantity%></td>
<td><%= product.price%></td>
</tr>
<% end -%>
如何将total_price保存到我的数据库?谢谢!将来自视图的数据保存到数据库中
谢谢!但我如何保留+ =功能? –
'集合中的物品'只是写作'collection.each do | item |'的另一种方式。为什么*不应该*他使用那个? – Mischa
没有工作。它说没有方法错误。 :( –