Skip to content

Commit 3f838c9

Browse files
authored
Merge pull request rails#53866 from MatheusRich/patch-1
Remove example from validation_context
2 parents 31aec23 + f9e7376 commit 3f838c9

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

activemodel/lib/active_model/validations.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -437,20 +437,6 @@ def validate!(context = nil)
437437
alias :read_attribute_for_validation :send
438438

439439
# Returns the context when running validations.
440-
#
441-
# This is useful when running validations except a certain context (opposite to the +on+ option).
442-
#
443-
# class Person
444-
# include ActiveModel::Validations
445-
#
446-
# attr_accessor :name
447-
# validates :name, presence: true, if: -> { validation_context != :custom }
448-
# end
449-
#
450-
# person = Person.new
451-
# person.valid? #=> false
452-
# person.valid?(:new) #=> false
453-
# person.valid?(:custom) #=> true
454440
def validation_context
455441
context_for_validation.context
456442
end

0 commit comments

Comments
 (0)