Ich habe eine Suche, die, wenn eine CPF digit zeigen alle Ergebnisse. Ok, aber ich brauche, die zeigen, auf diese Weise: (Nur eine Person und die Anzahl der Verträge, die es hat) * ist mein Code in portugiesisch, sorrykonsultieren Replikationswerte auf Ziffer cpf
Name
Registry
CPF
Contract 1 ---- Show all contracts
Contract 2 --------
Contract 3 -----------
Aber es zur Zeit kommt so: (The gleiche Werte entsprechend der Menge des Auftrags)
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 -----------
Es ist Werte replizierende ... weil Vertrag Nummer
Meine Ansicht ist dies:
<% 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%>
Dabei ist mein Controller:
wenn params [: pesquisa_func_cpf] .present? @autorizacoes = Autorizacao.pesquisa_func_cpf (params [: pesquisa_func_cpf]) alle
ich die .distinct versuchen statt .all, aber nicht funktionieren. (
Und mein konsultieren (ich benutze Oracle), es ist.
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'
Und es 3 Ergebnisse zurück, nach meinem Beispiel Bitte, wie gerade diese Struktur machen lassen:
Name
Registry
CPF
Contract 1 ---- Show all contracts
Contract 2 --------
Contract 3 -----------