From ea11af9568744a665f8ddc8f0cdca7407cc51d2b Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 2 Oct 2013 15:10:43 -0700 Subject: decouple belongs_to callback definition from the builder instance. All the information is on the reflection, so just get it there. --- activerecord/lib/active_record/associations/builder/belongs_to.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'activerecord/lib/active_record/associations') diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb index 1d9492a3bd..8d7ede1dbe 100644 --- a/activerecord/lib/active_record/associations/builder/belongs_to.rb +++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb @@ -14,8 +14,8 @@ module ActiveRecord::Associations::Builder def define_callbacks(model, reflection) super - add_counter_cache_callbacks(model, reflection) if options[:counter_cache] - add_touch_callbacks(model, reflection) if options[:touch] + add_counter_cache_callbacks(model, reflection) if reflection.options[:counter_cache] + add_touch_callbacks(model, reflection) if reflection.options[:touch] end def define_accessors(mixin, reflection) @@ -117,8 +117,8 @@ module ActiveRecord::Associations::Builder def add_touch_callbacks(model, reflection) foreign_key = reflection.foreign_key - n = name - touch = options[:touch] + n = reflection.name + touch = reflection.options[:touch] callback = lambda { |record| BelongsTo.touch_record(record, foreign_key, n, touch) -- cgit v1.2.3