Deleting many items


#1

Is there a quick and easy way to delete multiple items? I’d like to have
this in my list view:

<% for item in @items %>
…code with delete checkbox…
<% end %>

Then if a delete submit button at the end of the items list is clicked,
any item with its delete
checkbox would get deleted.

thanks
csn


Start your day with Yahoo! - Make it your home page!


#2

CSN,

You can do something like this:

View:
<%= check_box_tag “checked[#{item.id.to_s}]” %>

Controller:
Item.destroy(params[:checked].keys) unless params[:checked].nil?

You could use Item.delete if you don’t want to instantiate the objects
first.

Cody

On 12/5/05, CSN removed_email_address@domain.invalid wrote:

csn


http://www.codyfauser.com