Sha256: dedbd5bfcc28683c1e65d625eff53f1e75423a8c673fc6ad851e5abf5133e854
Contents?: true
Size: 670 Bytes
Versions: 1
Compression:
Stored size: 670 Bytes
Contents
# include into your AR models to get caching (expires when models updated_at changes) module TranslatedAttributes::Caching def self.included(base) base.class_eval do def merge_db_translations_with_instance_variable_with_cache key = "translated_attributes_#{cache_key}" if cached = Rails.cache.read key @translated_attributes = cached @db_translations_merged = true else merge_db_translations_with_instance_variable_without_cache Rails.cache.write key, @translated_attributes end end alias_method_chain :merge_db_translations_with_instance_variable, :cache end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
translated_attributes-0.6.1 | lib/translated_attributes/caching.rb |