AR - Delete m:n Associations when deleting Record

Hey!

I have three tables in my DB

users <--> users_courses <--> courses

users and courses are m:n related:

User: has_many :courses, :through => :user_courses

Course has_many :users, :through => :user_courses

I want to delete all records for a user in user_courses when deleting the user. How do i achieve that?

thx

Take a look at :dependent option in has_many method.