How should I implement mass deletion of records in a RESTful way? i.e.
from my index view I display a checkbox next to each record, and have
a submit button that will delete all of the checked boxes. Everything
I googled about RESTful deletion and the default destroy action is
related to destroying single records…
I’d imagine you’d have to create a new controller method for that…
IT’s still RESTful, just not perfect.
It’s my understsanding though that it’s acceptable… just like
creating a “search” action.
his complex form example… have them all marked up for Deletion
Check out this three part series.
Just extend his example from the attribute to the whole record…
shouldn’t be too hard.
Apply a collection to the restful, destroy/delete route.
I’m at work, and I forget the details, but it is similar to adding a
member to a route.
The delete works on the whole plural collection.
I’m assuming that you want to have a UI that allows a user to select
any number of records (say with checkboxes) then have that array of
records deleted in mass. Something like messages in a Google Mail
inbox for example. So you would also want to pass in the array of ids
to the custom controller action.
I think the point to the seven base actions in a RESTful controller is
not meant to restrict the controller to only these seven. Adding your
own custom methods does not break a RESTful controller, as long as the
base actions follow the convention.
What is important is that the API you construct with your controller
makes sense to a consumer of your controller as a service. Think,
“Would this break ActiveResouce’s ability to access this controller?”