aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-10-27 20:31:09 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-10-27 20:31:09 +0000
commit88f951a519d750236cc157566ef10f3977c933e1 (patch)
tree4966713bd6ec54a9cca12ba4c56ba25b8e81b81f /activerecord/lib/active_record/associations.rb
parenta55caf666cf4c00bdc5d73ac21ef92d6456cdf62 (diff)
downloadrails-88f951a519d750236cc157566ef10f3977c933e1.tar.gz
rails-88f951a519d750236cc157566ef10f3977c933e1.tar.bz2
rails-88f951a519d750236cc157566ef10f3977c933e1.zip
Allow association redefinition in subclasses. Closes #9346.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8046 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb6
1 files changed, 4 insertions, 2 deletions
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