def to_hash(full_messages = false)
      hash = {}
      message_method = full_messages ? :full_message : :message
      group_by_attribute.each do |attribute, errors|
        hash[attribute] = errors.map(&message_method)
      end
      hash
    end
def to_hash(full_messages = false)
      hash = {}
      message_method = full_messages ? :full_message : :message
      group_by_attribute.each do |attribute, errors|
        hash[attribute] = errors.map(&message_method)
      end
      hash
    end
Returns a Hash of attributes with their error messages. If +full_messages+
 is +true+, it will contain full messages (see +full_message+).

   person.errors.to_hash       # => {:name=>["cannot be nil"]}
   person.errors.to_hash(true) # => {:name=>["name cannot be nil"]}