Merge pull request #41217 from Vin0uz/active-model-errors-add-doc

[ci-skip] Adding options example in ActiveModel::Errors doc
This commit is contained in:
Rafael França 2021-02-03 16:18:26 -05:00 committed by GitHub
commit da418dc250
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -378,6 +378,14 @@ module ActiveModel
# If +type+ is a symbol, it will be translated using the appropriate
# scope (see +generate_message+).
#
# 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)"]
#
# If +type+ is a proc, it will be called, allowing for things like
# <tt>Time.now</tt> to be used within an error.
#