我在 html.erb 文件中有此内容。该文件是从一些带有渲染的视图文件中引用的。
<table>
<tr>
<th>image</th>
<th>name</th>
<th>description</th>
<th>status</th>
<th>Options</th>
</tr>
<% @activities.each do |activity| %>
<% if activity.in? @activities_completed then next; end %>
<tr>
<td><%= image_tag activity.photo.url(:thumb) %></td>
<td><%= activity.name %></td>
<td><%= activity.description %></td>
<td><%= (activity.in?(@activities_gotten)) ? (image_tag "pending_activity.png") : (image_tag "missing_activity.png") %></td>
<td>
<% if activity.in? @activities_gotten %>
<%= button_to 'Remove', {:controller => :bucket_items, :action => :remove, :id => activity.id} %>
<% else %>
<%= button_to 'Add', {:controller => :bucket_items, :action => :add, :id => activity.id} %>
<% end %>
<%= button_to 'Show', activity , :method => :get %>
</td>
</tr>
<% end %>
</table>
.each 的第一次迭代中带有按钮的 td 呈现为:
<td>
<div>
<input type="submit" value="Add">
<input name="authenticity_token" type="hidden" value="KyR2ftDGxNti7bZ2zpW/V+UGYUbHpZ+efxX4h48a6L0=">
</div>
<form action="/activities/10" class="button_to" method="get">
<div>
<input type="submit" value="Show">
</div>
</form>
</td>
而第二个和所有其他:
<td>
<form action="/bucket_items/remove?id=13" class="button_to" method="post">
<div>
<input type="submit" value="Remove">
<input name="authenticity_token" type="hidden" value="KyR2ftDGxNti7bZ2zpW/V+UGYUbHpZ+efxX4h48a6L0=">
</div>
</form>
<form action="/activities/13" class="button_to" method="get">
<div>
<input type="submit" value="Show">
</div>
</form>
</td>
显然某处存在问题,因为第一个按钮不起作用(显然,它周围没有表单标签),这是唯一一个不起作用的按钮。
关于这里发生了什么的任何线索?
谢谢,