表红宝石在轨道6上的嵌套循环查看错误的顺序

问题描述

我有一个类别,该类别具有工作注册。为了在表中显示这些,我使用下面的代码。但是,它以错误的方式执行。所有类别都打印在表格的顶部,然后所有工作注册都张贴在类别列表的下方。这对我来说很奇怪,因为工作注册循环是在类别循环中执行的。知道如何更正代码吗?我尝试使用group_by,但这会产生相同的结果。

<table id="dataWorkRegistrations" class="table table-lightborder" data-class="WorkRegistration">
    <thead>
      <tr>
        <th><%= t('work_registration.fields.code.label') %></th>
        <th><%= t('work_registration.fields.status.label') %></th>
        <th><%= t('work_registration.fields.name.label') %></th>
        <th><%= t('work_registration.fields.frequency.label') %></th>
        <th><%= t('work_registration.fields.amount.label') %></th>
      </tr>
    </thead>
    <tbody>
      <% @categories.each do |categorie| %>
        <tr class='bg-light'>
          <td><b><%= categorie.code %></b></td>
          <td>&nbsp;</td>
          <td><b><%= categorie.name %></b></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <% categorie.work_registrations.each do |work_registration| %>
            <tr>
              <td><%= work_registration.code %></td>
              <td><%= work_registration.status %></td>
              <td><%= work_registration.name %></td>
              <td><%= work_registration.frequency %></td>
              <td><%= work_registration.amount %></td>
            </tr>
        <% end %>
      <% end %>
    </tbody>
  </table>

解决方法

我设法解决了这个问题。作为表作为work_registrations的索引。数据表开始对所有内容进行排序,这导致了奇怪的排序。在对数据表禁用初始排序后,它立即生效。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...