I have
class MyContainer < ActiveRecord::Base :has_many MyObjects, :dependent => :destroy end
I want to delete all MyObjects in the container without deleting MyContainer . My model has :dependent => :destroy , but I do not want to delete and recreate the object, because it is slower.
Something like this does not work:
@obj = MyContainer.find_by_id(10) @obj.my_objects.delete_all
How can i do this?
ruby-on-rails children has-many
Dex
source share