【问题标题】:What formats does ActionView::Digestor.new accept for name?ActionView::Digestor.new 接受哪些名称格式?
【发布时间】:2015-03-08 09:45:10
【问题描述】:

我正在控制台中查看如何计算缓存摘要依赖项。这适用于 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 寻找这个部分?

【问题讨论】:

    标签: ruby-on-rails ruby actionview cache-digests


    【解决方案1】:

    根据source code,我希望这可行:

    ActionView::Digestor.digest(
      name:   'posts/_post', 
      finder:  finder,
      partial: true
    )
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-10
    • 2013-06-07
    • 2014-09-25
    • 2016-01-13
    • 2017-12-03
    • 1970-01-01
    • 2017-09-04
    相关资源
    最近更新 更多