rails/rails — Issue #3737: AS::Cache.expand_cache_key generates wrong key in certain situations
Author: exviva
Created: 2011-11-23 16:49:56+00:00
State: open

I've recently found the following problems with `ActiveSupport::Cache.expand_cache_key` ( https://github.com/rails/rails/blob/master/activesupport/lib/active_support/cache.rb#L75 ):

1. `cache_key` method is never called when the argument is a 1-element array with something that responds to `cache_key`
1. `nil` and `false` both expand to `""` (empty string), while `true` expands to `"true"`; I believe `false` should expand to `"false"`
1. `prefix` is added recursively when handling arrays
1. expanding an instance of `ActiveRecord::Relation` produces `"#"`

I'd say first two points are real bugs, while points 3 and 4 are just...surprising (I'm mentioning them to provoke a discussion).

I'm working on a patch that will expose and fix bugs 1 and 2.