Skip to content

Commit be5fbf3

Browse files
committed
Use #cache_key_with_key when available
In order to keep compatibility between the AMS cache feature and with Rails > 5.1 cache versioning, we have to use the `cache_key_with_version`. **NOTE** - This is a quick fix to the issue, if there will be future plans a proper cache versioning with recyclable key needs to be implemented. More info: #2287
1 parent 22f2cb7 commit be5fbf3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/active_model/serializer/concerns/caching.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ def expand_cache_key(parts)
283283
# Use object's cache_key if available, else derive a key from the object
284284
# Pass the `key` option to the `cache` declaration or override this method to customize the cache key
285285
def object_cache_key
286-
if object.respond_to?(:cache_key)
286+
if object.respond_to?(:cache_key_with_version)
287+
object.cache_key_with_version
288+
elsif object.respond_to?(:cache_key)
287289
object.cache_key
288290
elsif (serializer_cache_key = (serializer_class._cache_key || serializer_class._cache_options[:key]))
289291
object_time_safe = object.updated_at

0 commit comments

Comments
 (0)