咨询数字 cpf 上的复制值

Consult replicating values on digit cpf

我有一个搜索,当数字 CPF 显示所有结果。好的,但我需要这样显示: (只是一个人和它拥有的合同数量) * 我的代码是葡萄牙语,抱歉

Name
Registry
CPF
   Contract 1 ---- Show all contracts
   Contract 2   --------
   Contract 3 -----------

但它目前是这样的: (根据合同金额取相同数值)

Name
Registry
CPF
   Contract 1 ---- Show all contracts
   Contract 2   --------
   Contract 3 -----------

Name
Registry
CPF
   Contract 1 ---- Show all contracts
   Contract 2   --------
   Contract 3 -----------

Name
Registry
CPF
   Contract 1 ---- Show all contracts
   Contract 2   --------
   Contract 3 -----------

正在复制值...因为合约编号

我的看法是这样的:

<% if params[:pesquisa_func_cpf].present? %>
  <h4><b>Resultados</b></h4>
  <% @autorizacoes.each do |autorizacao| %>
    <table class="table table-condensed">
      <tr>
        <th>Name</th>
        <td><%= autorizacao.employee.person.name %></td>
      </tr>
      <tr>
        <th>Registry</th>
        <td><%= autorizacao.employee.registry %></td>
      </tr>
      <tr>
        <th>CPF</th>
        <td><%= autorizacao.employee.person.cpf %></td>
      </tr>
    </table>
    <hr />
    <table class="table table-condensed table-bordered">
      <th>Contract number</th>
      <% @autorizacoes.each do |autorizacao| %>
        <td><%= autorizacao.number_contract %></td>
      <% end %>
    </table>

  <% end %>
<% end%>

这是我的控制器:

如果参数[:pesquisa_func_cpf].存在? @autorizacoes = Autorizacao.pesquisa_func_cpf(参数[:pesquisa_func_cpf]).all

我尝试使用 .distinct 而不是 .all,但不起作用: (

还有我的咨询(我用的是oracle)是:

select * from autorizacoes INNER JOIN employers ON employers.id = autorizacoes.employer_id
                           INNER JOIN people ON employers.person_id = people.id
                           WHERE people.cpf  LIKE '111.111.111-11'

根据我的示例,它 return 3 个结果。拜托,如何只留下这个结构:

Name
Registry
CPF
   Contract 1 ---- Show all contracts
   Contract 2   --------
   Contract 3 -----------

我明白了!在我的控制器中,我只是这样:

if params[:pesquisa_func_cpf].present?
      @employers = Employee.pesquisa_cpf(params[:pesquisa_func_cpf]).all
      @autorizacoes = Autorizacao.pesquisa_func_cpf(params[:pesquisa_func_cpf]).all

我的观点是删除 <%= autorizacao.employee.person.name %> 并放置 <%= employee.person.name %>

仅此而已!