Hello again, What is the best way to delete all children of a parent in a controller. For example I have restaurants with a has_many association to boundaries. I would like to do something like this: @restaurant.boundaries.delete_all is it possible? steve -- 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-/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 -~----------~----~----~----~------~----~------~--~---
On Thu, Mar 27, 2008 at 04:59:45PM +0100, Steve Glaz wrote:> What is the best way to delete all children of a parent in a controller. > For example I have restaurants with a has_many association to > boundaries. I would like to do something like this: > > @restaurant.boundaries.delete_all > > is it possible?Look at collection.clear under http://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html#M001103> steve--Greg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Will do - thanks greg! Gregory Seidman wrote:> On Thu, Mar 27, 2008 at 04:59:45PM +0100, Steve Glaz wrote: >> What is the best way to delete all children of a parent in a controller. >> For example I have restaurants with a has_many association to >> boundaries. I would like to do something like this: >> >> @restaurant.boundaries.delete_all >> >> is it possible? > > Look at collection.clear under > http://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html#M001103 > >> steve > --Greg-- 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-/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 -~----------~----~----~----~------~----~------~--~---