我在控制台中探索如何计算缓存摘要依赖关系。这适用于app / views / posts / show.html.haml模板:
ActionView::Digestor.new(name: "posts/show", finder: finder).digest
# => Cache digest for app/views/posts/show.html.haml: 42bf3496bacfcf84492d8c05d81305fe
这些都不适用于app / views / posts / _post.html.haml模板:
ActionView::Digestor.new(name: "posts/_post", finder: finder).digest
# => Couldn't find template for digesting: posts/_post
ActionView::Digestor.new(name: "posts/post", finder: finder).digest
# => Couldn't find template for digesting: posts/post
(两者,finder = ApplicationController.new.lookup_context
)
如何告诉ActionView寻找这个部分?
答案 0 :(得分:1)
根据source code,我希望这有效:
ActionView::Digestor.digest(
name: 'posts/_post',
finder: finder,
partial: true
)