How a code can be given to an Application custom error messages in Ruby on Rails. when a user sees an error, he should be able to know both its error code and message.
For example, I want to achieve the following result, in case of respective error.
CODE Message
4081 You are not allowed to view the private document
5082 Company with this name already present
5034 Page removed
This is a multilingual application. Translations for error messages are present in /config/locales/en.yml. I'm using i18n gem for translation. This is how translation for error messages are present without code.
errors:
messages:
private_document: "You are not allowed to view the private document"
company_name: "Company with this name already present"
page_remove: "Page removed"