@@ -46,7 +46,7 @@ def reset_counters(id, *counters, touch: nil)
4646 counter_name = reflection . counter_cache_column
4747
4848 updates = { counter_name . to_sym => object . send ( counter_association ) . count ( :all ) }
49- updates . merge! ( touch_updates ( object , touch ) ) if touch
49+ updates . merge! ( touch_updates ( touch ) ) if touch
5050
5151 unscoped . where ( primary_key => object . id ) . update_all ( updates )
5252 end
@@ -105,8 +105,7 @@ def update_counters(id, counters)
105105 end
106106
107107 if touch
108- object = find ( id . is_a? ( Array ) ? id . first : id )
109- updates << object . class . send ( :sanitize_sql_for_assignment , touch_updates ( object , touch ) )
108+ updates << sanitize_sql_for_assignment ( touch_updates ( touch ) )
110109 end
111110
112111 unscoped . where ( primary_key => id ) . update_all updates . join ( ", " )
@@ -165,9 +164,9 @@ def decrement_counter(counter_name, id, touch: nil)
165164 end
166165
167166 private
168- def touch_updates ( object , touch )
169- touch = object . send ( : timestamp_attributes_for_update_in_model) if touch == true
170- touch_time = object . send ( : current_time_from_proper_timezone)
167+ def touch_updates ( touch )
168+ touch = timestamp_attributes_for_update_in_model if touch == true
169+ touch_time = current_time_from_proper_timezone
171170 Array ( touch ) . map { |column | [ column , touch_time ] } . to_h
172171 end
173172 end
0 commit comments