diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/integration.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/integration.rb b/activerecord/lib/active_record/integration.rb index 43f6afbb42..db7200bceb 100644 --- a/activerecord/lib/active_record/integration.rb +++ b/activerecord/lib/active_record/integration.rb @@ -97,13 +97,18 @@ module ActiveRecord # +false+ (which it is by default until Rails 6.0). def cache_version return unless cache_versioning - return unless has_attribute?("updated_at") - timestamp = updated_at_before_type_cast - if can_use_fast_cache_version?(timestamp) - raw_timestamp_to_cache_version(timestamp) - elsif timestamp = updated_at - timestamp.utc.to_s(cache_timestamp_format) + if has_attribute?("updated_at") + timestamp = updated_at_before_type_cast + if can_use_fast_cache_version?(timestamp) + raw_timestamp_to_cache_version(timestamp) + elsif timestamp = updated_at + timestamp.utc.to_s(cache_timestamp_format) + end + else + if self.class.has_attribute?("updated_at") + raise ActiveModel::MissingAttributeError, "missing attribute: updated_at" + end end end |