【发布时间】:2013-12-20 05:48:28
【问题描述】:
我有一个表,我正在从会话中加载值。
我正在处理更新按钮。我想将文本字段的当前值传递给控制器以执行更新操作。
我的代码如下所示:
<table>
<thead>
<tr>
<th width="200">Name</th>
<th width="150">Price</th>
<th>Quantity</th>
<th width="150">Total</th>
<th></th>
</tr>
<% grand_total = 0 %>
<% session[:cart].each do |key, item| %>
<tr>
<td><%= item[:name] %></td>
<td>Rs. <%= item[:price] %></td>
<td><%= text_field_tag(:quantity, item[:quantity]) %>
<%= link_to("Update", {:action => "update", :id => item[:id], :quantity => item[:quantity]}) %>
</td>
<td><%= item[:total_cost] %></td>
<td>
<%= link_to("X", {:action => "delete", :id => item[:id]}) %>
</td>
</tr>
<% grand_total = grand_total + item[:total_cost] %>
<% end %>
</thead>
</table>
当我将鼠标悬停在更新按钮上时,即使我更改了文本字段中的值,路径也会显示“localhost:3000/cart?quantity=1”。
【问题讨论】:
标签: javascript html ruby-on-rails ruby erb