avoid weird problem where #raise_on_type_mismatch incorrectly evaluates if the record is of the right type
bug fixes for rails 3 #raise_on_type_mismatch