【问题标题】:application.html.erb overriding other html filesapplication.html.erb 覆盖其他 html 文件
【发布时间】:2020-01-16 06:42:19
【问题描述】:

我有问题。我的问题是我的 application.html.erb 文件覆盖了所有其他 html 文件。这意味着当我尝试显示 static#welcome 时,仅显示我的应用程序 html 中的 html。开始获取"/" for ::1 at 2019-09-14 17:17:29 -0500 Processing by StaticController#welcome as HTML Rendering static/welcome.html.erb within layouts/application Rendered static/welcome.html.erb within layouts/application (0.4ms) Completed 200 OK in 28ms (Views: 24.6ms | ActiveRecord: 0.0ms) 这是我加载页面时在终端中显示的内容。

 <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %><%= csrf_meta_tags %><%= csp_meta_tag %>
 </head>
 <body>    
   <title>Stufinder</title>
<p>listening to my heart instead of my head<p>
 </body> ```


this is my application.html.erb file

   <h1>howdy , welcome to my page.</h1>
this is my welcome page

【问题讨论】:

    标签: html ruby-on-rails error-handling


    【解决方案1】:

    我通过在 application.html.erb 文件中添加一个等号解决了我的问题

    &lt;%= yield %&gt;

    【讨论】:

    • 就可以了。这是您的应用程序 html 世界的中心
    【解决方案2】:

    添加&lt;%= yield %&gt; 使其工作。 Yield 是 ruby​​ 中的一个关键词。它将接受一个发送到方法的块。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-03
      • 1970-01-01
      • 2015-05-14
      • 1970-01-01
      • 1970-01-01
      • 2019-07-22
      • 1970-01-01
      • 2012-09-02
      相关资源
      最近更新 更多