From c2b337183814cbd028407830509ce1da52e0e031 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 2 Oct 2013 14:34:51 -0700 Subject: decouple define_callback from the instance --- .../active_record/associations/builder/collection_association.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/associations/builder/collection_association.rb b/activerecord/lib/active_record/associations/builder/collection_association.rb index 7bd0687c0b..38a70f3efd 100644 --- a/activerecord/lib/active_record/associations/builder/collection_association.rb +++ b/activerecord/lib/active_record/associations/builder/collection_association.rb @@ -25,7 +25,9 @@ module ActiveRecord::Associations::Builder def define_callbacks(model, reflection) super - CALLBACKS.each { |callback_name| define_callback(model, callback_name) } + CALLBACKS.each { |callback_name| + define_callback(model, callback_name, reflection.name, reflection.options) + } end def define_extensions(model) @@ -35,7 +37,7 @@ module ActiveRecord::Associations::Builder end end - def define_callback(model, callback_name) + def define_callback(model, callback_name, name, options) full_callback_name = "#{callback_name}_for_#{name}" # TODO : why do i need method_defined? I think its because of the inheritance chain -- cgit v1.2.3