-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ci-skip] Adding options example in ActiveModel::Errors doc #41217
Conversation
@@ -381,6 +381,11 @@ def group_by_attribute | |||
# If +type+ is a proc, it will be called, allowing for things like | |||
# <tt>Time.now</tt> to be used within an error. | |||
# | |||
# If +type+ is compatible, +options+ will be injected in the translation. |
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.
Instead of placing this here, I would put it directly under the If +type+ is a symbol...
line and add an example with and without interpolation like:
person.errors.add(:name, :blank)
person.errors.messages
# => {:name=>["can't be blank"]}
person.errors.add(:name, :too_long, { count: 25 })
person.errors.messages
# => ["is too long (maximum is 25 characters)"]
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.
That's indeed a nicer way to do it, thank !
Could you please squash your commits in one? |
# person.errors.add(:name, :blank) | ||
# person.errors.messages | ||
# # => {:name=>["can't be blank"]} | ||
|
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.
# |
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.
馃檲 thanks
Place errors with variable example under the `type is a symbol` block Closes rails#41124
aef697f
to
da0e869
Compare
馃憢
This diff closes #41124
As stated in the issue, a quick example of how options can be used to be part of the generated message was missing, but appearing in another method doc (
added?
)I didn't move the piece in
added?
because it seems to be well-belonging there, but copied the example inadd