From fbaa5e390f018615bedb5e7c0f7ec2df24840963 Mon Sep 17 00:00:00 2001 From: "Ian C. Anderson" Date: Wed, 17 Aug 2016 10:25:04 -0400 Subject: i18n documentation for required belongs_to message When you don't explicitly provide `optional: true` to a `belongs_to` definition, rails adds a validation to ensure presence of the `belongs_to` validation. However, when the validation is added, it is added with a message key of `:required`, which was not documented in the "Translations for Active Record Models" section of the i18n guides. Here are the lines that add the `:required` message: https://github.com/rails/rails/blob/c3e3577f9d5058382504773bf0d32afa15cb131e/activerecord/lib/active_record/associations/builder/belongs_to.rb#L136-L138 This commit adds the "non-optional association" validation to the table, so rails users know how to override the message for this validation. The default message is "must exist". --- guides/source/i18n.md | 1 + 1 file changed, 1 insertion(+) (limited to 'guides') diff --git a/guides/source/i18n.md b/guides/source/i18n.md index e623f8cf8a..1565008a69 100644 --- a/guides/source/i18n.md +++ b/guides/source/i18n.md @@ -888,6 +888,7 @@ So, for example, instead of the default error message `"cannot be blank"` you co | inclusion | - | :inclusion | - | | exclusion | - | :exclusion | - | | associated | - | :invalid | - | +| non-optional association | - | :required | - | | numericality | - | :not_a_number | - | | numericality | :greater_than | :greater_than | count | | numericality | :greater_than_or_equal_to | :greater_than_or_equal_to | count | -- cgit v1.2.3