2
I created a relationship between the models client
and content
and I can access their data using the console
normally.
con = Content.find(1)
con.client.name # Nome do cliente
But when I try to access this data during a loop, I get the error that the name
has not been set/does not exist.
@content = Content.all
@content.each do |content|
puts content.title
puts content.target
puts content.client.name # O erro acontece aqui
Undefined method `name' for nil:Nilclass
the
client
has_many
Contents and thecontents
belongs_to
clients– RFL