Rails: print associations in ActiveRecord inspectors

Posted by marienbad on Stack Overflow See other posts from Stack Overflow or by marienbad
Published on 2010-06-04T06:18:11Z Indexed on 2010/06/04 6:19 UTC
Read the original article Hit count: 307

Filed under:
|

When I print an ActiveRecord of a Department, I get:

Department:0x210ec4c { :id => 3, :name => "Computer Science", ... :school_id => 3 }

How can I make it give me the School instead of the School_ID? In other words, call to_s on the school found by the school_id. Just like how when I have a Department d, I can say

d.school

© Stack Overflow or respective owner

Related posts about activerecord

Related posts about rails