【发布时间】:2016-04-09 02:44:50
【问题描述】:
我创建了一个 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 时,我显示的 url 是:/refinancimento/100,这个 refinanciamento 的值是:id: 100, funcionario_id: 2 我需要一个显示具有此 refinanciamento 的功能的地方。我如何构建这个咨询?
我的模型是:
class Refinanciamento < ActiveRecord::Base
belongs_to :funcionario
(...)
class Funcionario < ActiveRecord::Base
has_many :refinanciamentos
(...)
我只想显示创建 refinanciamento 的函数名称和矩阵。谢谢!
【问题讨论】:
-
"我只想显示已创建 refinanciamento 的函数的名称和矩阵。"您可能需要提供一些翻译来为读者提供上下文。
-
抱歉,我的系统是葡萄牙语的,因为我不会翻译,好吗?是“nome”和“matricula”
-
我猜nome是“name”,“matricula”、“pesquisa_cpf”和“Consult”是什么意思?
-
矩阵可以“注册”; pesquisa_cpf 可以是“search_cpf”,咨询就是咨询。
-
我相信
consult是query。pesquisa_cpf是一种根据文档编号搜索人员的方法。
标签: ruby-on-rails ruby ruby-on-rails-4 rails-4-2-1