【问题标题】:Rails Gretel not renderingRails Gretel 不渲染
【发布时间】:2014-02-21 22:19:22
【问题描述】:

所以我正在按照https://github.com/lassebunk/gretel 中的说明设置基本的 Gretel 安装。

这是我的面包屑.rb

crumb :root do
 link 'Root', root_path
end

这是show.html中的代码。haml(我的观点是用haml编码的)

= breadcrumb :root

还有application.html.haml

= breadcrumbs pretext: "You are here: ", separator: " › "

现在我得到的渲染类似于

http://grab.by/uyFW

知道可能出了什么问题吗?我期待一个带有测试“Root”的面包屑

【问题讨论】:

  • 能否分享一下生成的HTML源代码?
  • 我不能完整的 html,但这是重要的部分......就像是试图渲染对象 grab.by/uyGI

标签: ruby-on-rails ruby breadcrumbs


【解决方案1】:

替换

= breadcrumb :root
= breadcrumbs pretext: "You are here: ", separator: " › "

- breadcrumb :root

= breadcrumbs pretext: "You are here: ", separator: " › "

【讨论】:

  • 实际上,如果我使用-,它会完全停止工作。根本没有渲染
  • @Pablo 我已经更新了答案。你需要= 上的breadcrumbs- 上的breadcrumb
  • 当面包屑是根级别并且是当前页面时,有没有办法强制呈现?
  • @Pablo 没完全明白你的问题?你的意思是说在 root_path 上也显示面包屑。
  • @Pablo 你读过github.com/lassebunk/gretel 页面吗?在那里你会看到一个选项:autoroot,你可以通过将它设置为True将它传递给你的面包屑我以前从未使用过HAML,但我认为以下方法会起作用。 = breadcrumbs pretext: "You are here: ", separator: " › ", autoroot: True 试试看是否可行。
【解决方案2】:

我遇到了同样的问题,在我们的案例中,唯一的问题是我们甚至试图查看根页面的面包屑。

根据 gem wiki,参数 ":display_single_fragment" 默认设置为 false。该参数是不言自明的。

下面的代码按预期工作:

- breadcrumb :portfolios
= breadcrumbs pretext: "You are here: ", separator: " › ", :autoroot => true, :display_single_fragment => true

【讨论】:

    【解决方案3】:

    对于链接单链接,您必须在应用程序控制器中将“display_single_fragment”属性设置为 true

        <%= breadcrumbs pretext: "current link", display_single_fragment: "true" %>
    

    【讨论】:

      【解决方案4】:

      改变

      = breadcrumb :root
      

      - breadcrumb :root
      

      希望对你有帮助。

      【讨论】:

        猜你喜欢
        • 2011-03-20
        • 1970-01-01
        • 1970-01-01
        • 2017-05-07
        • 2011-12-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多