이 코드에서는 사용자가 여러 항목을 한꺼번에 삭제할 수있는 기능을 제공하는 체크 박스가 있지만 항목을 확인하지 않고 제거 버튼을 누르면 오류가 발생합니다 :레일에서 컨트롤러로 보내기 전에 값을 확인하십시오.
<% form_for :product , :url => { :action => :delete_selected } do %>
<table border="1px">
<tr>
<th>
Select
</th>
<th>
Image
</th>
<th>
Product Name
</th>
<th>
Product Description
</th>
<th>
Product Price
</th>
<th>
Categories
</th>
<th colspan="3">
Actions
</th>
</tr>
<% @products.each do |p| %>
<tr>
<td>
<%= check_box_tag "product_ids[]", p.id, false, :id => "product_#{p.id}" %>
</td>
<td>
<%= image_tag p.photo.url(:thumb) , :alt => "#{p.name}" %>
</td>
<td>
<%= link_to "#{p.name}" , edit_product_path(p) %>
</td>
<td>
<%=h truncate(p.description.gsub(/<.*?>/,''),:length => 80) %>
</td>
<td>
<%=h p.price %>
</td>
<td>
<% for category in p.categories.find(:all) %>
<%= link_to "#{category.name}" , category_path(category.id) %>
<% end %>
</td>
<td>
<%= link_to 'Show' , product_path(p) %>
</td>
<td>
<%= link_to 'Edit', edit_product_path(p) %>
</td>
<td>
<%= link_to 'Remove', product_path(p), :confirm => "Are you really want to delete #{p.name} ?", :method => 'delete' %>
</td>
<% end %>
</tr>
</table>
<div id="products_nav">
<%= link_to "Add a new Product" , new_product_path %>
<%= link_to "Add a new Category" , new_category_path %>
<%= link_to "Category page" , categories_path %>
<%= submit_tag "Remove selected items" , :confirm => "Are you really want to delete these items ?" %>
</div>
<% end %>
나는 컨트롤러에 보내기 전에이를 확인하고 사용자에게 경고를 제공하거나이 컨트롤러에서 수행해야 할 수 있나요?
여러 항목을 동시에 편집 할 수있는 다른 방법을 추가하려는 경우이 양식을 사용 할 수 있습니까? 한 가지 양식에 대해 다른 조치를 취하는 것이 가능하다는 뜻입니까?