rails/rails — pull request #14260 by TemaMix (2014-03-03 16:17:31+00:00)
Title: Activemodal::Errors added methods error_message_format and i18n_priority_format

error_message_format - returns an I18n key of an error message taking into consideration the format of an error message. If none found the default value is being returned (errors.format).

Formats are first looked up in "activerecord.errors.models.MODEL.attributes.ATTRIBUTE.format", if it's not there, it's looked up in "activerecord.errors.models.MODEL.format" and if that is not there also, it returns default format (e.g. "errors.format").

i18n_priority_format - returns array that defined format priority key for i18n scope an error message. Last array element have highest priority.
person.errors.i18n_priority_format # => [:"errors.format"]
person.errors.i18n_priority_format(:name)
# => [:"errors.format",
# :"activemodel.errors.models.person.format",
# :"activemodel.errors.models.person.attributes.name.format"]