rails/rails — pull request #11452 by dasch (2013-07-15 14:03:07+00:00)
Title: Bust the template digest cache key when details are changed

Since the lookup details will influence which template is resolved, they need to be included in the cache key -- otherwise two different templates may erroneously share the same digest value.

I hit a bug where two templates being treated as the same, causing rendering bugs in production. I discovered that it was due Cache Digests – the digest remained the same even if the details were different.

I'm using details like this:

```ruby
module MobileViewResolution
ActionView::LookupContext.register_detail(:devices) { [] }

extend ActiveSupport::Concern

included do
path = Rails.root.join("app", "views")
pattern = ":prefix/:action{.:devices,}{.:formats,}{.:handlers,}"
resolver = ActionView::FileSystemResolver.new(path, pattern)
prepend_view_path(resolver)
end

private

def details_for_lookup
if mobile_request?
devices = ["mobile"]
else
devices = []
end

super.merge(devices: devices)
end
end
```