-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix inaccurate docs in active_model errors [ci skip] #18099
Fix inaccurate docs in active_model errors [ci skip] #18099
Conversation
@@ -263,7 +263,7 @@ def to_hash(full_messages = false) | |||
|
|||
# Adds +message+ to the error messages on +attribute+. More than one error | |||
# can be added to the same +attribute+. If no +message+ is supplied, | |||
# <tt>:invalid</tt> is assumed. | |||
# <tt>:invalid</tt> is assumed (but not if the +message+ is nil). |
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.
I think the current documentation already cover this.
If no +message+ is supplied, <tt>:invalid</tt> is assumed.
If you pass nil you are suppling a nil 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.
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.
I think RF is right, saying "no +message+ is supplied" should be enough to say that passing nil
is still passing something. Therefore :invalid
won't be used for the message when nil
is given.
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.
A couple of minor details:
message
is not a noun. You can refer "the message" with an article if "message" goes in regular font, or to message
without article. For example, a user may be logged in, but in a method RDoc you'd say "user
is an instance of User
" (not "the user
").
Also, nil
should go in fixed-width font.
So, it would be
# <tt>:invalid</tt> is assumed (but not if +message+ is +nil+).
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.
NIce. Thanks! 😄
Awesome! Thank you for working on this |
@rafaelfranca My pleasure! |
Speaking of returned value Because a structure like |
The default value for the argument `message` in `ActiveModel::Errors#add` has a new behavior since ca99ab2. Before person.errors.add(:name, nil) # => ["is invalid"] After person.errors.add(:name, nil) # => [nil]
@egilburg I'm not sure what you mean.. @robsonmarques Thank you for the patch! |
…add_docs Fix inaccurate docs in active_model errors [ci skip]
@zzak You're welcome! 😄 |
The default value for the argument
message
inActiveModel::Errors#add
has a new behaviorsince ca99ab2.