From 88f951a519d750236cc157566ef10f3977c933e1 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 27 Oct 2007 20:31:09 +0000 Subject: Allow association redefinition in subclasses. Closes #9346. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8046 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/associations.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index e542e8d85a..654b24d71c 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -955,7 +955,7 @@ module ActiveRecord # Don't use a before_destroy callback since users' before_destroy # callbacks will be executed after the association is wiped out. old_method = "destroy_without_habtm_shim_for_#{reflection.name}" - class_eval <<-end_eval + class_eval <<-end_eval unless method_defined?(old_method) alias_method :#{old_method}, :destroy_without_callbacks def destroy_without_callbacks #{reflection.name}.clear @@ -1351,7 +1351,9 @@ module ActiveRecord defined_callbacks = options[callback_name.to_sym] if options.has_key?(callback_name.to_sym) class_inheritable_reader full_callback_name.to_sym - write_inheritable_array(full_callback_name.to_sym, [defined_callbacks].flatten) + write_inheritable_attribute(full_callback_name.to_sym, [defined_callbacks].flatten) + else + write_inheritable_attribute(full_callback_name.to_sym, []) end end end -- cgit v1.2.3