From 7d98247446e9f043dc9b6b5cbdb938877dd00a81 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Mon, 3 Mar 2014 20:50:31 -0500 Subject: Cache key should be different when is Array. `cache.fetch(['foo'])` and `cache.fetch('foo')` should generate different cache keys as they are not equivalents. [related #8615] [related #8614] --- activesupport/lib/active_support/cache.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index a627fa8651..f23f6f16d6 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -511,7 +511,7 @@ module ActiveSupport # called. If the key is a Hash, then keys will be sorted alphabetically. def expanded_key(key) # :nodoc: return key.cache_key.to_s if key.respond_to?(:cache_key) - + trailing_slash = false case key when Array if key.size > 1 @@ -519,11 +519,12 @@ module ActiveSupport else key = key.first end + trailing_slash = true when Hash key = key.sort_by { |k,_| k.to_s }.collect{|k,v| "#{k}=#{v}"} end - - key.to_param + key = key.to_param + trailing_slash ? "#{key}/" : key end # Prefix a key with the namespace. Namespace and key will be delimited -- cgit v1.2.3