Code style changes for various activerecord errors

as discussed in #17674