Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

decouple belongs_to callback definition from the builder instance.

All the information is on the reflection, so just get it there.
  • Loading branch information...
commit ea11af9568744a665f8ddc8f0cdca7407cc51d2b 1 parent 743f1a9
@tenderlove tenderlove authored
View
8 activerecord/lib/active_record/associations/builder/belongs_to.rb
@@ -14,8 +14,8 @@ def self.valid_dependent_options
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 @@ def self.touch_record(o, foreign_key, name, touch) # :nodoc:
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)
Please sign in to comment.
Something went wrong with that request. Please try again.