Method: ActiveRecord::Integration#cache_version
- Defined in:
- activerecord/lib/active_record/integration.rb
#cache_version ⇒ Object
Returns a cache version that can be used together with the cache key to form a recyclable caching scheme. By default, the #updated_at column is used for the cache_version, but this method can be overwritten to return something else.
Note, this method will return nil if ActiveRecord::Base.cache_versioning is set to false.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'activerecord/lib/active_record/integration.rb', line 97 def cache_version return unless cache_versioning if has_attribute?("updated_at") = updated_at_before_type_cast if can_use_fast_cache_version?() () elsif = updated_at .utc.to_fs() end elsif self.class.has_attribute?("updated_at") raise ActiveModel::MissingAttributeError, "missing attribute 'updated_at' for #{self.class}" end end |