method
each
each()
public
Iterates through each error key, value pair in the error messages hash. Yields the attribute and the error for that attribute. If the attribute has more than one error message, yields once for each error message.
p.errors.add(:name, "can't be blank") p.errors.each do |attribute, errors_array| # Will yield :name and "can't be blank" end p.errors.add(:name, "must be specified") p.errors.each do |attribute, errors_array| # Will yield :name and "can't be blank" # then yield :name and "must be specified" end