Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.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 4.0中渲染表_Ruby On Rails_View_Partial - Fatal编程技术网

Ruby on rails 在部分Rails 4.0中渲染表

Ruby on rails 在部分Rails 4.0中渲染表,ruby-on-rails,view,partial,Ruby On Rails,View,Partial,有人能帮我渲染一个表视图吗?基本上,我有一个带有两个属性的链接模型:Description和URL。我的链接模型是我的机会模型的嵌套资源。因此,当我单击opportunity上的“show”时,我希望它显示opportunity,然后显示属于该opportunity的所有链接。我希望将链接呈现到一个表中,表中的列标记为“Description”和“URL”。我当前的代码如下所示: 意见/机会: <%= render @opportunity %> <h3>Links<

有人能帮我渲染一个表视图吗?基本上,我有一个带有两个属性的链接模型:Description和URL。我的链接模型是我的机会模型的嵌套资源。因此,当我单击opportunity上的“show”时,我希望它显示opportunity,然后显示属于该opportunity的所有链接。我希望将链接呈现到一个表中,表中的列标记为“Description”和“URL”。我当前的代码如下所示:

意见/机会:

<%= render @opportunity %>
<h3>Links</h3>
<div id = "links">
  <%= render @opportunity.links %>
</div>

链接
视图/链接/\u链接

<%= div_for link do %>

    <p>Description:<%= link.description %></p>
    <p>URL: <%= link.link_url %></p>
    <span class='actions'>
            <%= link_to 'Delete', [@opportunity, link], :confirm => 'Are you sure?',
                :method => :delete %>
    </span>
<% end %>

说明:

网址:

“你确定吗?”, :方法=>:删除%>
您需要

<%= render @opportunity %>
<h3>Links</h3>
<table id = "links">
  <thead><tr>
    <th>Description</th>
    <th>URL</th>
  </tr></thead>

  <tbody>
    <%= render @opportunity.links %>
  </tbody>
</table>

链接
描述
统一资源定位地址
然后

<tr>
  <td><%= link.description %></td>
  <td><%= link.link_url %></td>
  <td><span class='actions'>
        <%= link_to 'Delete', [@opportunity, link], :confirm => 'Are you sure?',
            :method => :delete %>
  </span></td>
</tr>

“你确定吗?”,
:方法=>:删除%>
我有点不清楚你是如何在部分中使用跨度的,所以我把它作为一个单独的列放在表中

我希望这有帮助