How can I add a property to child association before render?

Posted by ChrisInCambo on Stack Overflow See other posts from Stack Overflow or by ChrisInCambo
Published on 2010-05-19T03:27:04Z Indexed on 2010/05/19 3:30 UTC
Read the original article Hit count: 262

Filed under:

Hi,

I have a teacher model which has_many students. When I render a student (as json) I want to strip out the teacher_id property and replace it with the name of the teacher in my representation.

What is the best way to achieve this?

Cheers,

Chris

© Stack Overflow or respective owner

Related posts about ruby-on-rails