David
David

Reputation: 4465

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.

Upvotes: 5

Views: 1009

Answers (1)

Toby Hede
Toby Hede

Reputation: 37133

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.

Upvotes: 8

Related Questions