0
I have two related tables in Rails, pessoa
and cidade
.
On the table pessoa
have the field cidade_id
.
How to do, for example, p = Pessoa.find(1)
and in place of p.cidade_id
already return the name of the city without I need to do p.cidade.nome
?
thanks very much worked out, I’m using as api so just use render :json => @people.to_json(:include => :city) in the controller that returns 1 json {people: {id: 1, name: "test"...} city:{id:1 name: ...} }
– leo Castro