我創建了一個refinanciamento,而且我的節目不正確。請教我不想要的工作方式
show.html.erb
<p>
<strong>Nome:</strong>
<%= @funcionario.pessoa.nome %>
</p>
<p>
<strong>Matrícula:</strong>
<%= @funcionario.matricula %>
</p>
當我把@ funcionario.first.pessoa.nome,它的 「工作」,但是,再回到第一個,我不想這樣,肯定的。
我的控制器:
def show
@funcionario = Funcionario.pesquisa_cpf(params[:pesquisa_func_cpf]).first
@refinanciamento = Refinanciamento.find(params[:id])
end
例如,當我註冊一個refinanciamento,我上節目的網址是:/ refinancimento/100,這refinanciamento的數值:ID:100,funcionario_id:2 我需要一個那裏顯示有這個refinanciamento的funcionario。我如何構建這個諮詢?
我的車型有:
class Refinanciamento < ActiveRecord::Base
belongs_to :funcionario
(...)
class Funcionario < ActiveRecord::Base
has_many :refinanciamentos
(...)
我只是想表明諾姆和funcionario的matricula有創建的refinanciamento。謝謝!
「我只是想顯示nin和matricula of funcionario有refinanciamento創建。」您可能需要提供一些翻譯以提供給讀者上下文。 –
對不起,但我的系統是葡萄牙語,因爲我不翻譯,好嗎?是「nome」和「matricula」 –
我猜nome是「名稱」,你是什麼意思的「matricula」,「pesquisa_cpf」和「諮詢」? mandarula可以「註冊」; –