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... TIA. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. You could always use Javascript helpers kinda like Ryan Bates does in his complex form example.... have them all marked up for Deletion using Ajax. Check out this three part series. http://railscasts.com/episodes/73 http://railscasts.com/episodes/74 http://railscasts.com/episodes/75 Just extend his example from the attribute to the whole record... shouldn''t be too hard. On Apr 29, 11:19 am, Juan Lupión <pantu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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... > > TIA.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On Apr 29, 8:53 am, sw0rdfish <san...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. > > You could always use Javascript helpers kinda like Ryan Bates does in > his complex form example.... have them all marked up for Deletion > using Ajax. > > Check out this three part series. > > http://railscasts.com/episodes/73http://railscasts.com/episodes/74http://railscasts.com/episodes/75 > > Just extend his example from the attribute to the whole record... > shouldn''t be too hard. > > On Apr 29, 11:19 am, Juan Lupión <pantu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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... > > > TIA.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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?" On Apr 29, 12:51 pm, Ruby Freak <twscann...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. > > On Apr 29, 8:53 am, sw0rdfish <san...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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. > > > You could always use Javascript helpers kinda like Ryan Bates does in > > his complex form example.... have them all marked up for Deletion > > using Ajax. > > > Check out this three part series. > > >http://railscasts.com/episodes/73http://railscasts.com/episodes/74htt... > > > Just extend his example from the attribute to the whole record... > > shouldn''t be too hard. > > > On Apr 29, 11:19 am, Juan Lupión <pantu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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... > > > > TIA.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---