I have the following AR models defined:
class Venue < ActiveRecord::Base
has_many :events
end
class Act < ActiveRecord::Base
has_many :events
end
class Event < ActiveRecord::Base
belongs_to :venue
belongs_to :act
end
What I want is if I delete a Venue or Act, any associated Events are also deleted. But if I delete an Event, the associated Venue and Act are NOT deleted. I’ve tried various :dependent variations, but nothing seems to be working.
This seems so simple. What am I missing?
I figured out the problem. I had to call
destroyinstead ofdeleteon the parent object. The docs don’t really make that clear.