Skip to content

Commit fc6fa81

Browse files
committed
Use fragment_cache_key when available so caches are properly expired
1 parent b56455b commit fc6fa81

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/jbuilder/jbuilder_template.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ def _render_partial(options)
104104

105105
def _cache_key(key, options)
106106
key = _fragment_name_with_digest(key, options)
107-
key = url_for(key).split('://', 2).last if ::Hash === key
107+
108+
if @context.respond_to?(:fragment_cache_key)
109+
key = @context.fragment_cache_key(key)
110+
else
111+
key = url_for(key).split('://', 2).last if ::Hash === key
112+
end
113+
108114
::ActiveSupport::Cache.expand_cache_key(key, :jbuilder)
109115
end
110116

0 commit comments

Comments
 (0)