Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 为什么可以';我在Michael Hartl第11章练习1中呈现了一个部分';s轨道教程?_Ruby On Rails_Ruby_Railstutorial.org_Partials - Fatal编程技术网

Ruby on rails 为什么可以';我在Michael Hartl第11章练习1中呈现了一个部分';s轨道教程?

Ruby on rails 为什么可以';我在Michael Hartl第11章练习1中呈现了一个部分';s轨道教程?,ruby-on-rails,ruby,railstutorial.org,partials,Ruby On Rails,Ruby,Railstutorial.org,Partials,我正在尝试完成,但是当我在浏览器中加载页面时,我看不到呈现的部分 简介如下: 重构主页,为if-else语句的两个分支使用单独的部分 我尝试加载部分内容的主页模板如下: <% if logged_in? %> <% render 'shared/home_logged_in' %> <% else %> <% render 'shared/home_not_logged_in' %> <% end %> <di

我正在尝试完成,但是当我在浏览器中加载页面时,我看不到呈现的部分

简介如下:

重构主页,为if-else语句的两个分支使用单独的部分

我尝试加载部分内容的主页模板如下:

<% if logged_in? %>
    <% render 'shared/home_logged_in' %>
<% else %>
    <% render 'shared/home_not_logged_in' %>
<% end %>
<div class="center jumbotron">
  <h1>Welcome to the Sample App</h1>

  <h2>
    This is the home page for the
    <a href="http://www.railstutorial.org/">Ruby on Rails Tutorial</a>
    sample application.
  </h2>

  <%= link_to "Sign up now!", signup_path, class: "btn btn-lg btn-primary" %>
</div>

<%= link_to image_tag("rails.png", alt: "Rails logo"),
            'http://rubyonrails.org/' %>

我正在尝试加载的一个部分的示例如下:

<% if logged_in? %>
    <% render 'shared/home_logged_in' %>
<% else %>
    <% render 'shared/home_not_logged_in' %>
<% end %>
<div class="center jumbotron">
  <h1>Welcome to the Sample App</h1>

  <h2>
    This is the home page for the
    <a href="http://www.railstutorial.org/">Ruby on Rails Tutorial</a>
    sample application.
  </h2>

  <%= link_to "Sign up now!", signup_path, class: "btn btn-lg btn-primary" %>
</div>

<%= link_to image_tag("rails.png", alt: "Rails logo"),
            'http://rubyonrails.org/' %>

欢迎使用示例应用程序
这是网站的主页
示例应用程序。
我的代码可以在GitHub上找到,并且可以找到我为完成此练习所做的更改

我做错了什么?

您使用的是
而不是
。您需要将表达式打印到页面缓冲区中,以便将其包含在响应中

<% "I am invisible" %>
<%= "I am not" %>


向github存储库添加链接很好,但是如果您需要调试帮助,您应该在问题主体中添加相关代码。这是一个很好的礼貌的人谁准备帮助你和保护,以防止链接腐烂。问题已更新,以包含我正在使用的代码。我还包括了我试图完成的练习的简要说明,以进一步避免链接腐烂(如果到教程书的链接断开/更改)。我已替换