is there a way i can get a rake task to destroy the dependents declared in the model when an item is destroyed?
here is my rake task code:
task(:deleteFakes => :environment) do @items = Item.find(:all, :conditions => 'items.fake = true', :order => 'name')
@items.each do |item| item.destroy puts item.name + " destroyed!" end end
and part of the item model:
has_many :compounds, :dependent => :destroy
if i delete the items through the web interface the item and it's associated compounds are removed. is there a way i can get this to work from the rake task?
thanks. scott