New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Formatting Full Messages with I18n section in ActiveRecordValidations guides [ci-skip] #45470
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about putting this information under config.active_model.i18n_customize_full_message
instead? We could perhaps streamline the examples to use a single model with ActiveModel::Validations
and a single validation on two different attributes. Then we could add a comment like # or `activerecord:` if using Active Record validations
next to the activemodel:
key in the YAML.
@jonathanhefner the suggested change sounds good. I really feel that it's relevant for validations and i18n too and left in the configuration page is really hiding the information. Can we also add a link on these guides to the configuration example? I'm thinking here: 7.3 errors.where and error object under
and here: active-model-methods on this paragraph
I'll put some links in the meantime. |
@AlexB52 Sounds good! 👍 |
0706a1c
to
2fea677
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor comments. Almost there! 😃
Also, when you're finished, would you mind squashing the commits?
guides/source/configuring.md
Outdated
|
||
When set to `true`, `full_message` will look for a format at the attribute and model level of the locale files. The default format is `"%{attribute} %{message}"`, where `attribute` is the name of the attribute, and `message` is the validation-specific message. The following example overrides the format for all `Person` attributes, as well as the format for a specific `Person` attribute (`age`). | ||
|
||
[ActiveModel::Error#full_message]: https://api.rubyonrails.org/classes/ActiveModel/Error.html#method-i-full_message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this reference below the example, at the end of this section, above the ### Configuring Active Record
heading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I just moved the link below the code example. I hope this is what you meant and not the paragraph starting with
when set to 'true'...
e835480
to
fb49e1e
Compare
@jonathanhefner Can you please check if the commit message suits you? I have a backup of all the commits in case a standard squash with the 12 commits in the description is necessary. Thanks for the help |
…eRecord Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
fb49e1e
to
0dd813c
Compare
There was a commit that accidentally removed a line break. (I probably should have included the line break in #45470 (comment).) I forced pushed a commit to fix it though, so we're good to go. Thank you for working on this, @AlexB52! 👍 (Backported to |
Add Formatting Full Messages with I18n section in ActiveRecordValidations guides [ci-skip] (cherry picked from commit e722b74)
Summary
This PR adds a section on the ActiveRecordValidation guides to demonstrate how full validation messages can be formatted with the help of I18n.
Other Information
This PR was extracted from the PR proposal: #42708
While the feature didn't get any traction, the documentation of the existing behaviour to format full messages is currently missing.