html表呈现为未格式化的<a> tags

时间:2015-09-25 13:31:23

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

Got a bit of a strange thing going on with an HTML table that I'm trying to render for my index view. Below is my view:

<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>

My problem is that no such table renders. Instead I get this mess:

<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>

It's not like this is a problem anywhere else on the site; I've got tables all over the place that render very nicely. I know I'm not giving you much to work with but that's pretty much all I've got. Any ideas?

1 个答案:

答案 0 :(得分:0)

在h1标记的末尾放置一个结束>,因为它遗漏了它:<h1>Assets</h1