Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mass action in restful ways with rails?

what is your idea of mass action still sticking with rails restful out of the box methods? like a mass delete.

I was tempted to create a mass_delete method already on my controller can't seem to wrap my head around if there's any existing or more elegant way to handle mass actions.

just shopping for ideas.

thanks.

like image 656
David Avatar asked Feb 13 '11 04:02

David


1 Answers

You can make the delete be a "collection" method in you routes

resources :items do
  collection do
    delete 'delete'
  end
end

This will create an "/items/delete" - the idea being that you are now working on the collection of Item resources.

Also; I am actually not 100% sure that you can use the delete verb here, and I don't think there is anything particularly wrong with adding your own methods to the controller.

like image 92
Toby Hede Avatar answered Oct 20 '22 22:10

Toby Hede