Module: ActiveRecordTweaks::Integration
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_record_tweaks/integration.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#cache_key_without_timestamp ⇒ Object
Returns a cache key that can be used to identify this record.
Instance Method Details
#cache_key_without_timestamp ⇒ Object
Returns a cache key that can be used to identify this record. Timestamp is not used to allow custom caching expiration (e.g. Cookie based caching with expiration )
Product.new.cache_key # => "products/new"
Product.find(5).cache_key # => "products/5" (updated_at not available)
Person.find(5).cache_key # => "people/5" (updated_at available)
14 15 16 17 18 19 20 21 |
# File 'lib/active_record_tweaks/integration.rb', line 14 def case when new_record? "#{self.class.model_name.cache_key}/new" else "#{self.class.model_name.cache_key}/#{id}" end end |