title: Destroy all records associated with object in Rails 4
body: <p>I have a database of movies and their associated genres. </p>
  
  <pre><code>class Genre &lt; ActiveRecord::Base
    has_many :movie_genres
    has_many :movies, through: :movie_genres, dependent: delete_all
    before_destroy :delete_movie
  
    private
  
    def delete_movie
      self.movies.delete_all
    end
  
  end
  
  class Movie &lt; ActiveRecord::Base
    has_many :movie_genres
    has_many :genres, through: :movie_genres
  end
  </code></pre>
  
  <p>My aim is that when a genre gets deletes - all of its movies also get deleted, regardless of if that movie has another genre or not. I've tried attaching dependent: :destroy to the Genre model however only the join table records get deleted. I've also tried using the before_destroy callback to delete the movies prior to deleting the genre however that didn't seem to work either.</p>