【问题标题】:<%= yield %> not inserting page content<%= yield %> 不插入页面内容
【发布时间】:2017-04-09 13:12:08
【问题描述】:

我正在对更新到新的 Rails 版本进行常规修订。我正在使用 Michael Hartl 的 Ruby on Rails 教程(Rails 5)。我正在构建他的 sample_app。 application.html.erb 正如预期的那样有一个 &lt;%= yield %&gt; 调用,它没有插入页面内容。有人知道为什么会这样吗?

终端显示:在救援中渲染 /var/lib/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatc‌​h/middleware/templat‌​es/rescues/routing_e‌​rror.html.erb /layout 当我尝试加载页面时。

这是 application.html.erb

<`!DOCTYPE html> 
<html> 
  <head> 
    <title><%= full_title(yield(:title)) %></title> 
    <%= csrf_meta_tags %> 
    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 
    <%= render 'layouts/shim' %> 
  </head> 
  <body> 
    <%= render 'layouts/header' %> 
    <%= yield %> 
    <%= render 'layouts/footer' %> 
  </body> 
</html>`

【问题讨论】:

  • 您有错误吗?显示了什么?
  • @gleb 列出您的application.html.erb 代码
  • ' '
  • 终端显示:在rescues/中渲染/var/lib/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb当我尝试加载页面时的布局
  • 您能否向我们展示您的控制器/视图和 routes.eb。这似乎与您的路线有关。

标签: ruby-on-rails ruby-on-rails-5 railstutorial.org


【解决方案1】:

我重新创建了应用程序并偷​​走了application.html.erb 我把它放在原来的应用程序中。有效!!出于好奇,我替换了原来的application.html.erb,它起作用了??????

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-20
    • 1970-01-01
    • 2019-03-23
    • 1970-01-01
    • 2012-11-01
    相关资源
    最近更新 更多