rename type column and fix before_save callback condition