check box

There are probably better ways, but here's how I would do it:

Create a check box for every row, and assign it a name that's based on
the id of the record displayed, along the lines of:

for item in @items
<td><%= check_box 'delete_check_' %></td>

For each checkbox that is checked, the form will return
params[:delete_check_xxx] (xxx being the id number) So in your
controller, check for the existence of params[:delete_check_xxx] while
xxx < @items.length, for each one that's found, find the item by the id
and destroy it.

Better would be something like:

<%= check_box_tag "delete_check[#{}]", value = true %>

Then the params come into your method as a hash of results:

  Parameters: {"action"=>"index", "delete_check"=>{"23"=>"true",
"47"=>"true"}, "controller"=>"whatever"}

Then you can iterate over all the checked items:

params[:delete_check].each_key do |delete_id|

David Schmidt

zero halo wrote: