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_'+item.id.to_s %></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[#{item.id}]", 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|   .... end

David Schmidt

zero halo wrote: