I have created a relationship between the client
and content
models and I can access their data using 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 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