I have this model
class XmlImport < ActiveRecord::Base
belongs_to :video
belongs_to :user
has_many :events, through: :event_import_records, dependent: :destroy
has_many :event_import_records, dependent: :destroy
has_attached_file :xml
validates_attachment_content_type :xml, :content_type => ["text/xml"]
end
The :event_import_records
entries are being destroyed. But the :events
are not.
- Is the
dependent:destroy
on thehas_many through
association valid? - Is there another way of writing it? If that is not correct
- How can I destroy all the
events
associated to theXmlImport
through theevent_import_records
?