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
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---