From 8ea64bd0fce854a4bb85bf67c983d30358c8cd39 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 1 Aug 2013 11:36:39 -0700 Subject: remove more mutations from the `build` method --- .../associations/builder/has_and_belongs_to_many.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb index 64ee24c7c6..55ec3bf4f1 100644 --- a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb +++ b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb @@ -8,13 +8,8 @@ module ActiveRecord::Associations::Builder super + [:join_table, :association_foreign_key] end - def build - reflection = super - define_destroy_hook - reflection - end - - def define_destroy_hook + def define_callbacks(model, reflection) + super name = self.name model.send(:include, Module.new { class_eval <<-RUBY, __FILE__, __LINE__ + 1 -- cgit v1.2.3