Hi! I have 3 tables. animal studies, species and provenances, where:
estudoanimais belongs_to especie
estudoanimais has_many_procedencias
especie has_many estudoanimais
procedencia belongs_to estudoanimal
At the moment I create a provenance, I can associate this to a species, drawn from a select as follows:
f.select :estudoanimais_id, Estudoanimal.all.collect{|ea| [ea.especie.nome,ea.id]}
What I would like is to show the name of this chosen species instead of its id on the originals screens. In the console, I'm trying to do it like this:
p=Procedencia.first
nome = p.estudoanimal.especie.nome
and he says he can not bring that name because it's a null value, but if I put it:
p.estudoanimais_id
It brings the value of the id of the species that I chose when creating a provenance. Where am I going wrong?