Skip to content

Commit

Permalink
Add docs for Active Record validation with multiple contexts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
notapatch authored and danielvdao committed May 1, 2023
1 parent cad4664 commit 4d52690
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions activerecord/lib/active_record/validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def save!(**options)
#
# If the argument is +false+ (default is +nil+), the context is set to <tt>:create</tt> if
# {new_record?}[rdoc-ref:Persistence#new_record?] is +true+, and to <tt>:update</tt> if it is not.
# If the argument is an array of contexts, <tt>post.valid?([:create, :update])</tt>, the validations are
# run within multiple contexts.
#
# \Validations with no <tt>:on</tt> option will run no matter the context. \Validations with
# some <tt>:on</tt> option will only run in the specified context.
Expand Down

0 comments on commit 4d52690

Please sign in to comment.