encodeWithCoder properly encodes has_one relationships as well