Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.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 rails中缺少用于渲染的部分_Ruby On Rails - Fatal编程技术网

Ruby on rails rails中缺少用于渲染的部分

Ruby on rails rails中缺少用于渲染的部分,ruby-on-rails,Ruby On Rails,我创建了部分调用_topics_list.form.html.erb的代码 <table class="list" cellspaceing="0"> <thead class="head_list"> <tr> <th class="column">Name</th> <th class="column">Description</th> </tr> </the

我创建了部分调用_topics_list.form.html.erb的代码

<table class="list" cellspaceing="0">
  <thead class="head_list">
  <tr>
    <th class="column">Name</th>
    <th class="column">Description</th>
  </tr>
  </thead>
  <% @topics.each do |topic| %>
    <tr class="row">
      <td data-label="Name" class="column first"><%= topic.name %></td>
      <td data-label="Description" class="column column_problem">
        <%= link_to topic.description, topic_path(topic), class:"link_for_column_problem" %>
      </td>
      <td data-label="Date" class="column"><%= topic.created_at.strftime("%d %b, %Y") %></td>
    </tr>
  <% end %>
</table>
更新

<p id="notice"><%= notice %></p>

<h1 class="request_headline">All Topics</h1>
<%= render 'topics_list'%>

<table>
  <thead>
    <tr>
      <th colspan="3"></th>
    </tr>
  </thead>

  <tbody>
    <% @topics.each do |topic| %>
      <tr>
        <td><%= link_to 'Show', topic %></td>
        <td><%= link_to 'Edit', edit_topic_path(topic) %></td>
        <td><%= link_to 'Destroy', topic, method: :delete, data: { confirm: 'Are you sure?' } %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<br>

<%= link_to 'New Topic', new_topic_path %>

所有主题
我渲染部分的代码

尝试更改

<p id="notice"><%= notice %></p>

<h1 class="request_headline">All Topics</h1>
<%= render 'topics_list'%>

所有主题

所有主题
另外,一个好主意是始终将局部变量传递给分部,而不是使用全局变量,这样您就可以绝对控制分部中的值。

然后部分使用

<table class="list" cellspaceing="0">
  <thead class="head_list">
  <tr>
    <th class="column">Name</th>
    <th class="column">Description</th>
  </tr>
  </thead>
  <% topics.each do |topic| %>
    <tr class="row">
      .....
      .....
    </tr>
  <% end %>
</table>

名称
描述
.....
.....

您的部分名称是
\u topics\u list.form.html.erb
。要呈现此内容,您需要调用
render'主题列表。表单'
,而不是
render'主题列表'

您可以在尝试呈现
topics/\u主题列表的位置共享代码吗?
是的,当然,已更新
<p id="notice"><%= notice %></p>

<h1 class="request_headline">All Topics</h1>
<%= render 'topics/topics_list' %>

<table class="list" cellspaceing="0">
  <thead class="head_list">
  <tr>
    <th class="column">Name</th>
    <th class="column">Description</th>
  </tr>
  </thead>
  <% topics.each do |topic| %>
    <tr class="row">
      .....
      .....
    </tr>
  <% end %>
</table>