Forum: Ruby on Rails Deleting many items

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
cool_screen_name90001 (Guest)
on 2005-12-05 22:02
(Received via mailing list)
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!
http://www.yahoo.com/r/hs
codyfauser (Guest)
on 2005-12-05 22:30
(Received via mailing list)
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
This topic is locked and can not be replied to.