-
Notifications
You must be signed in to change notification settings - Fork 1
Optional Attribute Prefix
lulalala edited this page Apr 18, 2017
·
3 revisions
Rails always prefix attributes to the error messages. Only if errors are on the :base
attribute would prefix be avoided.
This is however not always desired, especially in other languages. Some have developed plugins to solve this issue, for example adding "^" character to denote a prefix-less message. This however seems hacky.
Since different translations of the same error to have different prefix setting, This implies that it must be conveyed at the same place as the locale messages, e.g. yaml file.
Provide way to set a flag when adding errors. For two methods: errors.add()
and errors.add_without_prefix()
. This sets a flag in error object, which determines whether prefix is added or not.