【发布时间】:2013-12-17 15:19:15
【问题描述】:
我有一张包含价格和数量字段的表格。我想将价格 * 数量添加到我最终添加到表格中的每个项目的总计中。
我的代码如下所示。
<table>
<thead>
<tr>
<th width="200">Name</th>
<th width="150">Price</th>
<th>Quantity</th>
<th width="150">Total</th>
</tr>
<% @item.each do |item| %>
<tr>
<td><%= item.name %></td>
<td><%= item.price %></td>
<td><%= item.quantity %></td>
<td><%= item.quantity * item.price %></td>
<td class="actions">
<% link_to("update", :class => 'action update') %>
<% link_to("X", :class => 'action delete') %>
</td>
</tr>
<% end %>
</thead>
</table>
我的总数是标签的形式。 我该怎么做呢? RoR中有静态变量的概念吗??
【问题讨论】:
-
使用数据库进行这些操作
-
如果您对此感到满意,请不要忘记接受答案。它将帮助贡献者。
标签: html ruby-on-rails ruby