I created a refinanciamento and my show doesn't correct.

show.html.erb

<p> <strong>Nome:</strong> <%= @funcionario.pessoa.nome %> </p> <p> <strong>Matrícula:</strong> <%= @funcionario.matricula %> </p>

When I put @funcionario.first.pessoa.nome, it "work" but, ever return the first, I don't wanna this, sure.

My controller:

def show @funcionario = Funcionario.pesquisa_cpf(params[:pesquisa_func_cpf]).first @refinanciamento = Refinanciamento.find(params[:id]) end

Example, when I register a refinanciamento, my url on show is: /refinancimento/100, this refinanciamento have the values: id: 100, funcionario_id: 2 I need a where that show the funcionario that have this refinanciamento. How I build this consult?

My models are:

class Refinanciamento < ActiveRecord::Base belongs_to :funcionario (...) class Funcionario < ActiveRecord::Base has_many :refinanciamentos (...)

I just want show nome and matricula of funcionario that have the refinanciamento created. Thanks!