I have found a solution to show data
in patient controller i make this
in controller patients
def weight
end
And created view weight.html.slim
p#notice = notice
.row
p
table
thead
tr
th Nome:
th Sexo:
th Data de nascimento:
th Idade:
tbody
tr
td = @patient.name
td = @patient.sex.name
td = @patient.born
td = ((Date.today - @patient.born) / 365).to_i
p
table
thead
tr
th Plano:
th Senha de internação:
th Admimissão:
th Altura:
tbody
tr
td = @patient.plan.name
td = @patient.pass
td = @patient.admission
- if @patient.weight.first.inch != nil
td = @patient.weight.first.inch
- else
td = 'Paciente sem altura registrada'
p
table
thead
tr
th Data
th Peso
th IMC:
strong pesos:
tbody
- @patient.weight.each do |m|
tr
- if m.date != nil
td = m.date
- else
td = 'Sem pesos registrados'
- if m.weight != nil
td = m.weight
- else
td = 'sem peso registrado'
- if @patient.weight.first.inch != nil
td = (m.weight / (@patient.weight.first.inch**2).to_f).round(2)
- else
td = 'sem dados para este calculo'
br´
and in index.html.erb
<td><a href="/peso/<%= patient.id %>" target="_blank">Relatorio</a></td>
In routes.rb
get 'peso/:id/', to: 'patients#weight'
And solved my problem