简体   繁体   English

Rails已呈现但未出现

[英]Rails rendered but doesn't appear

Please excuse my english if it's not perfect. 如果不是很完美,请原谅我的英语。

I know there are already different topics about this type of problem but none has brought an effective solution in my case. 我知道关于这种类型的问题已经有不同的话题,但没有一个能为我带来有效的解决方案。

I have a sidebar and in logs, I can see it's rendered but it doesn't appear in the view or when I inspect the elements. 我有一个侧边栏,并且在日志中,我可以看到它已渲染,但是它没有出现在视图中或当我检查元素时。

I don't see any error in the code but maybe you'll see something. 我没有在代码中看到任何错误,但也许您会看到一些东西。

_sidebar.slim: _sidebar.slim:

= content_for(:leftbar) do
  .leftbar-nav
    .leftbar-content
      .leftbar-block
        = render('shared/clients_ratings')
      .leftbar-block
        = render('themes/list')
      .leftbar-block
        = render('shared/social_share')
      .cta-block
        = widget_content('sidebar-list-public-orders')

Rendered in _orders.slim: 在_orders.slim中呈现:

- unless identity_signed_in?
  = render 'shared/cta_blocks'

- if @orders.size > 0
    = render @orders
    = paginate @orders
- else
  p
    | There are no orders.

= render('themes/sidebar')

Rendered in index.slim: 在index.slim中呈现:

- content_for(:full_width) do
  .neo-page-header
    .container
      .neo-page-header-title
        h1 Title

  .container
    = render('orders/orders')

Finally, I have a content_for?(:leftbar) in my application.slim: 最后,我的application.slim中有一个content_for?(:leftbar):

doctype html
html lang="fr"
  = render "layouts/head"
  body class= "#{yield(:app_class)}"
    #wrap
      = render 'shared/flash_messages'
      = render 'shared/admin_navbar'
      - if identity_signed_in?
        = render 'shared/navbar'
      - else
        = render 'shared/navbar_guest'
      = render 'shared/banner' unless hide_banner? or identity_signed_in?

      = render('shared/confirmation_notice')

      - if content_for(:full_width)
        = yield(:full_width)

      - elsif content_for?(:sidebar)
        .container
          .row
            .col-lg-9.col-md-9
              = yield
            .col-lg-3.col-md-3
              = yield :sidebar

      - elsif content_for?(:leftbar)
        .container
          .row
            .col-lg-3.col-md-3
              = yield :leftbar
            .col-lg-9.col-md-9.main-content
              = yield
      - else
        .container
          = yield

In your application.slim you have - if content_for(:full_width) . application.slim您具有- if content_for(:full_width) This probably returns some truthy value so any other elsif won't be executed. 这可能会返回一些真实值,因此不会执行其他任何elsif I believe it should be - if content_for?(:full_width) 我相信应该- if content_for?(:full_width)

应该是= yield :leftbar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM