diff options
author | Arthur Neves <arthurnn@gmail.com> | 2014-03-03 20:50:31 -0500 |
---|---|---|
committer | Arthur Neves <arthurnn@gmail.com> | 2014-03-03 21:00:15 -0500 |
commit | 7d98247446e9f043dc9b6b5cbdb938877dd00a81 (patch) | |
tree | 1f4e2225b5249e68ab00bd1227cb59bb47c79a0a /activesupport/lib/active_support | |
parent | ffcc6172b4d40ca7c8b02fd298c679b5bcf5787b (diff) | |
download | rails-7d98247446e9f043dc9b6b5cbdb938877dd00a81.tar.gz rails-7d98247446e9f043dc9b6b5cbdb938877dd00a81.tar.bz2 rails-7d98247446e9f043dc9b6b5cbdb938877dd00a81.zip |
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]
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/cache.rb | 7 |
1 files changed, 4 insertions, 3 deletions
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 |