Skip to content

Commit da418dc

Browse files
authored
Merge pull request rails#41217 from Vin0uz/active-model-errors-add-doc
[ci-skip] Adding options example in ActiveModel::Errors doc
2 parents 7265111 + da0e869 commit da418dc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

activemodel/lib/active_model/errors.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,14 @@ def group_by_attribute
378378
# If +type+ is a symbol, it will be translated using the appropriate
379379
# scope (see +generate_message+).
380380
#
381+
# person.errors.add(:name, :blank)
382+
# person.errors.messages
383+
# # => {:name=>["can't be blank"]}
384+
#
385+
# person.errors.add(:name, :too_long, { count: 25 })
386+
# person.errors.messages
387+
# # => ["is too long (maximum is 25 characters)"]
388+
#
381389
# If +type+ is a proc, it will be called, allowing for things like
382390
# <tt>Time.now</tt> to be used within an error.
383391
#

0 commit comments

Comments
 (0)