Skip to content

Commit 5b25375

Browse files
committed
Add docs for Active Record validation with multiple contexts
The PR documents this change: rails#21535 Which allows multiple contexts to be validated: person.valid?([:create, :update]) # => true The change isn't visible in the API documentation which this PR fixes.
1 parent a1a026f commit 5b25375

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

activerecord/lib/active_record/validations.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def save!(**options)
6262
#
6363
# If the argument is +false+ (default is +nil+), the context is set to <tt>:create</tt> if
6464
# {new_record?}[rdoc-ref:Persistence#new_record?] is +true+, and to <tt>:update</tt> if it is not.
65+
# If the argument is an array of contexts, <tt>post.valid?([:create, :update])</tt>, the validations are
66+
# run within multiple contexts.
6567
#
6668
# \Validations with no <tt>:on</tt> option will run no matter the context. \Validations with
6769
# some <tt>:on</tt> option will only run in the specified context.

0 commit comments

Comments
 (0)