Rails .erb 文件渲染顺序错误

Rails .erb file rendering in wrong order

我有以下 .erb 文件:

<div class="table-responsive">
    <table class="table table-striped">
      <thead>
        <tr>
          <th>Name</th>
          <th>Email</th>
          <th>Delete</th>
        </tr>
      </thead>
      <tbody>
        <%= form_for @group, html: { id: 'form' } do |group_form| %>
            <div id="group-members">
            <%= group_form.fields_for :group_members do |group_member_fields| %>
                <tr>
                    <td><%= group_member_fields.text_field :name , class: 'form-control' %></td>
                    <td><%= group_member_fields.email_field :email, class: 'form-control' %></td>
                    <td><%= group_member_fields.check_box :_destroy %></td>
                </tr>
            <% end %>
            </div>
      </tbody>
    </table>
</div>
<%= group_form.submit 'Apply', class: "btn btn-success btn-sm pull-right" %>
<% end %> <!-- End of form -->
<%= submit_tag 'Add member', type: 'button', class: "btn btn-primary btn-md", id: "add-member-to-group-btn" %>

form_for 正下方 idgroup-membersdiv 显示为空且位置错误。 fields_for 中的元素仍然正确呈现,只是不在 group-members div.

只允许 <tr> 个元素作为 <tbody> 的子元素。您应该将 table 移到表格内。然后,您可以将属性 id="group-members" 移动到不同的元素,例如 <form><tbody><table>.

在HTML中,如果要在<table>中使用<div>标签,则必须在<th><td>中。欲了解更多信息,请在此处查看 post:

https://css-tricks.com/using-divs-inside-tables/