diff --git a/activerecord/lib/active_record/integration.rb b/activerecord/lib/active_record/integration.rb index 94abdb3ec7d1a32d0909f63c335075932e5f9daa..f88c8e30e6c3decaf00c2f94635281fa36695baf 100644 --- a/activerecord/lib/active_record/integration.rb +++ b/activerecord/lib/active_record/integration.rb @@ -55,8 +55,8 @@ def cache_key(*timestamp_names) when new_record? "#{self.class.model_name.cache_key}/new" when timestamp_names.any? - timestamps = timestamp_names.collect { |method| send(method) }.compact - timestamp = timestamps.max.utc.to_s(cache_timestamp_format) + timestamp = max_updated_column_timestamp(timestamp_names) + timestamp = timestamp.utc.to_s(cache_timestamp_format) "#{self.class.model_name.cache_key}/#{id}-#{timestamp}" when timestamp = max_updated_column_timestamp timestamp = timestamp.utc.to_s(cache_timestamp_format) diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb index 9253150c4f46d5a2382bbd5dcb7ddb53e0df5de0..e0541b7681e49d21e2fd8a616a8306b3f2ca68cb 100644 --- a/activerecord/lib/active_record/timestamp.rb +++ b/activerecord/lib/active_record/timestamp.rb @@ -98,8 +98,8 @@ def all_timestamp_attributes timestamp_attributes_for_create + timestamp_attributes_for_update end - def max_updated_column_timestamp - if (timestamps = timestamp_attributes_for_update.map { |attr| self[attr] }.compact).present? + def max_updated_column_timestamp(timestamp_names = timestamp_attributes_for_update) + if (timestamps = timestamp_names.map { |attr| self[attr] }.compact).present? timestamps.map { |ts| ts.to_time }.max end end