I have a many-to-many relationship like this:
class Event < ActiveRecord::Base has_many :calendar_events has_many :calendars, :through => :calendar_events # ... end
I want to make it so that when I call some_event.destroy Ruby on Rails deletes the association records from the calendar_events table. Based on the API documentation, I’m assuming you do this…
class Event < ActiveRecord::Base has_many :calendar_events, :dependent => :delete_all has_many :calendars, :through => :calendar_events # ... end
Is that the right way to do it?
Yes. That will delete all the calendar events only.