Hi, Using "resources :object" in my routes file, the DELETE operation operates by default on an individual member (i.e. it requires an ''id'' to be specified). I''d like to change this so that DELETE is a collection route, so that I can call it without having to specify an id and still have the route match through to the destroy method. I''m new to Rails routes, so any help would be much appreciated! Thanks, - Nex -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi, a collection routes is meant to work on the whole collection. Example for a collection delete would be for example to delete all books that are out of print. If you want to delete a particular book the member route is perfect....how would you otherwise know in your controller, which book to delete? Markus -- http://www.communityguides.eu On Sunday, March 20, 2011 5:05:19 PM UTC+1, Ruby-Forum.com User wrote:> > Hi, > > Using "resources :object" in my routes file, the DELETE operation > operates by default on an individual member (i.e. it requires an ''id'' to > be specified). > > I''d like to change this so that DELETE is a collection route, so that I > can call it without having to specify an id and still have the route > match through to the destroy method. > > I''m new to Rails routes, so any help would be much appreciated! > > Thanks, > > - Nex > > -- > Posted via http://www.ruby-forum.com/. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Markus, I think I haven''t been clear enough, the default resource is set up for individual members, rake routes gives me this: ... DELETE /appearances/:id(.:format) ... Whereas I actually want to create a route for deleting a collection: ... DELETE /appearances ... But I don''t believe this is created by default, I get a no route error when calling delete on just the controller without an id. So in short - I actually want to have a route to delete a whole collection, but the default resources method in routes.rb creates a delete method for a member, and doesn''t set up a route for deleting a collection. I would like to know how to add a delete route for a collection. Thanks! Markus Proske wrote in post #988427:> Hi, > > a collection routes is meant to work on the whole collection. Example > for a > collection delete would be for example to delete all books that are out > of > print. If you want to delete a particular book the member route is > perfect....how would you otherwise know in your controller, which book > to > delete? > > Markus > > -- > http://www.communityguides.eu-- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 March 2011 17:12, Peter Laurens <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi Markus, > > I think I haven''t been clear enough, the default resource is set up for > individual members, rake routes gives me this: > > ... > DELETE /appearances/:id(.:format) > ... > > Whereas I actually want to create a route for deleting a collection: > > ... > DELETE /appearancesHow will this identify *which* collection of appearances you want to delete? Colin> ... > > But I don''t believe this is created by default, I get a no route error > when calling delete on just the controller without an id. > > So in short - I actually want to have a route to delete a whole > collection, but the default resources method in routes.rb creates a > delete method for a member, and doesn''t set up a route for deleting a > collection. I would like to know how to add a delete route for a > collection. > > Thanks! > > Markus Proske wrote in post #988427: >> Hi, >> >> a collection routes is meant to work on the whole collection. Example >> for a >> collection delete would be for example to delete all books that are out >> of >> print. If you want to delete a particular book the member route is >> perfect....how would you otherwise know in your controller, which book >> to >> delete? >> >> Markus >> >> -- >> http://www.communityguides.eu > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
That''s a good question, and perhaps I''m heading down the wrong path. But I intend to pass a parameter in the HTTP body that will determine the type of appearances objects to remove. Because I would like the delete operation to delete a collection of appearances dependent on whether they belong to a certain person for example. So my intention was to send the DELETE, and then a ''person'' parameter in the body of the DELETE request would determine which appearances to delete. This widens the discussion slightly, but perhaps you could give guidance on the validity of this model of doing things? Many thanks again Colin Law wrote in post #988435:> On 20 March 2011 17:12, Peter Laurens <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> >> ... >> DELETE /appearances > > How will this identify *which* collection of appearances you want to > delete? > > Colin-- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Well, you can prevent Rails from creating that route for you using :except or :only in the routes.rb and then add a collection route with the same name (if you need examples on that, you can follow the link in my signature). Technically that solves your problem. But this is for removing a collection, for example an admin action to delete all logs older than x-month. Can you explain with an example what your really want to do? Markus -- http://www.communityguides.eu On Sunday, March 20, 2011 6:12:16 PM UTC+1, Ruby-Forum.com User wrote:> > Hi Markus, > > I think I haven''t been clear enough, the default resource is set up for > individual members, rake routes gives me this: > > ... > DELETE /appearances/:id(.:format) > ... > > Whereas I actually want to create a route for deleting a collection: > > ... > DELETE /appearances > ... > > But I don''t believe this is created by default, I get a no route error > when calling delete on just the controller without an id. > > So in short - I actually want to have a route to delete a whole > collection, but the default resources method in routes.rb creates a > delete method for a member, and doesn''t set up a route for deleting a > collection. I would like to know how to add a delete route for a > collection. > > Thanks! > > Markus Proske wrote in post #988427: > > Hi, > > > > a collection routes is meant to work on the whole collection. Example > > for a > > collection delete would be for example to delete all books that are out > > of > > print. If you want to delete a particular book the member route is > > perfect....how would you otherwise know in your controller, which book > > to > > delete? > > > > Markus > > > > -- > > http://www.communityguides.eu > > -- > Posted via http://www.ruby-forum.com/. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.