1
Hi! I have 3 tables. studies, species and origins, where :
estudoanimais belongs_to especie
estudoanimais has_many_procedencias
especie has_many estudoanimais
procedencia belongs_to estudoanimal
The moment I create a provenance, I can associate that with a species, pulled 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 provenance screens. On the console, I’m trying to do it this way:
p=Procedencia.first
nome = p.estudoanimal.especie.nome
and he says that he cannot bring that name because it is a null value, but if I put:
p.estudoanimais_id
it brings the id value of the species I chose when creating a source. Where am I missing?
Have you tried using the
collection_select
? Worked on the last Rails project I did– Victor Matheus Tavares