Skip to content

Commit da0e869

Browse files
committed
Adding options example in ActiveModel::Errors doc
Place errors with variable example under the `type is a symbol` block Closes rails#41124
1 parent af9c910 commit da0e869

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)