开发rails时遇到了线路问题。容器中元素的顺序是
<div class="container">
<%= yield %>
<%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %>
</div>
对于大多数页面,它运作良好。但是当它呈现下一页
时会出错<% provide(:title, 'All Apps') %>
<h1>All Apps</h1>
<table class="apps table">
<thead>
<tr>
<th>App Name</th>
<th>Status</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<%= render @apps %>
</tbody>
</talbe>
容器中元素的顺序变为
<div class="container">
<h1>All Apps</h1>
<footer class="footer">...</footer>
<pre class="debug_dump">...</pre>
<table class="app table">...</table>
</div>
令我困惑的是,只有这个页面出错了。我正在使用Rails 4.0.5。
答案 0 :(得分:2)
最有可能发生的事情是您的浏览器HTML解析器正在尝试修复问题,方法是在表格之前将元素“浮动”放在表中(不在tr>td
中)。你可能有一个未封闭的标签。
(这就是为什么在这样的情况下检查生成的html并将其与浏览器的DOM面板进行比较的重要性 - 它可能会非常不同!)