【问题标题】:html table rendering as an unformatted bunch of <a> tagshtml 表格呈现为一组未格式化的 <a> 标签
【发布时间】:2015-09-25 13:31:22
【问题描述】:

我尝试为我的索引视图呈现的 HTML 表发生了一些奇怪的事情。以下是我的看法:

<div class="container-fluid" style="margin-top:51px">
    <h1>Assets</h1
    <table id="indexTable" class="table table-hover">
        <thead>
            <tr>
                <th>Uploaded Files</th>
            </tr>
        </thead>
        <tbody>
            <% @assets.each do |asset| %>
                <tr>
                    <td><%= link_to asset.uploaded_file_file_name, asset.uploaded_file.url %></td>
                    <td><%= link_to "Show", asset %></td>
                    <td><%= link_to "Edit", edit_asset_path(asset) %></td>
                    <td><%= link_to "Destroy", asset, :confirm => 'Are you sure?', :method => :delete %></td>
                </tr>
            <% end %>
        </tbody>
    </table>
    <p><%= link_to "New Asset", new_asset_path %></p>
</div>

我的问题是没有这样的表格呈现。相反,我得到了这个烂摊子:

<div class="container-fluid" style="margin-top:51px">
  <h1>Assets</h1>
  Uploaded Files
  <a href="/uploaded_files/original/missing.png">/uploaded_files/original/missing.png</a>
  <a href="/assets/1">Show</a>
  <a href="/assets/1/edit">Edit</a>
  <a rel="nofollow" href="/assets/1" data-method="delete" confirm="Are you sure?">Destroy</a>
  <a href="/uploaded_files/original/missing.png">/uploaded_files/original/missing.png</a>
  <a href="/assets/2">Show</a>
  <a href="/assets/2/edit">Edit</a>
  <a rel="nofollow" href="/assets/2" data-method="delete" confirm="Are you sure?">Destroy</a>
  <a href="/system/assets/uploaded_files/000/000/003/original/500SO.png?1443185486">500SO.png</a>
  <a href="/assets/3">Show</a>
  <a href="/assets/3/edit">Edit</a>
  <a rel="nofollow" href="/assets/3" data-method="delete" confirm="Are you sure?">Destroy</a>
</div>

这并不是网站上其他任何地方的问题;我到处都有桌子,渲染得非常好。我知道我不会给你太多的工作,但这几乎就是我所拥有的。有什么想法吗?

【问题讨论】:

  • 你错过了 H1 的收盘价>
  • 您将什么发送回浏览器......希望它的 index.html.erb 并注意您的 html 视图中使用的所有标签

标签: html ruby-on-rails ruby-on-rails-4 erb


【解决方案1】:

在您的 h1 标记末尾放置一个结束 &gt;,因为它缺少它:&lt;h1&gt;Assets&lt;/h1

【讨论】:

  • 这里不值得回答。
  • 是的,哇,这太糟糕了。这是一个通宵,也许我需要在伤害自己之前离开键盘。不过谢谢
猜你喜欢
  • 2014-10-14
  • 2023-01-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-14
  • 2019-07-29
  • 1970-01-01
相关资源
最近更新 更多