# File lib/active_record/associations.rb, line 1410 def has_and_belongs_to_many(association_id, options = {}, &extension) reflection = create_has_and_belongs_to_many_reflection(association_id, options, &extension) collection_accessor_methods(reflection, HasAndBelongsToManyAssociation) # Don't use a before_destroy callback since users' before_destroy # callbacks will be executed after the association is wiped out. include Module.new { class_eval "def destroy # def destroy\nsuper # super\n\#{reflection.name}.clear # posts.clear\nend # end\n", __FILE__, __LINE__ + 1 } add_association_callbacks(reflection.name, options) end