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:destroyon thehas_many throughassociation valid? - Is there another way of writing it? If that is not correct
- How can I destroy all the
eventsassociated to theXmlImportthrough theevent_import_records?