diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index 5e2c7b411d26bd335a18a8467ef901b7dddce9e7..98af88b5a06436f9a9d66bec0c90354520019245 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -71,8 +71,8 @@ module ClassMethods
# end
#
# Options:
- # * :on - Specifies the context where this validation is active
- # (e.g. :on => :create or :on => :special_rules)
+ # * :on - Specifies the context where this validation is active
+ # (e.g. :on => :create or :on => :custom_validation_context)
# * :allow_nil - Skip validation if attribute is +nil+.
# * :allow_blank - Skip validation if attribute is blank.
# * :if - Specifies a method, proc or string to call to determine
diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb
index fba44defc1116279c6f17cd9ffebfec0e7b54395..4f390613aa82fa360404a4bc47eb833b0e652d18 100644
--- a/activemodel/lib/active_model/validations/acceptance.rb
+++ b/activemodel/lib/active_model/validations/acceptance.rb
@@ -37,9 +37,9 @@ module HelperMethods
# Configuration options:
# * :message - A custom error message (default is: "must be
# accepted").
- # * :on - Specifies when this validation is active (default is
- # nil, other options are :create and
- # :update).
+ # * :on - Specifies when this validation is active. Runs in all
+ # validation contexts by default (+nil+), other options are :create
+ # and :update.
# * :allow_nil - Skip validation if attribute is +nil+ (default
# is true).
# * :accept - Specifies value that is considered accepted.
diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb
index bcefc7d888c43a01913f04802b3d68b9e2edc329..e6d10cfff845e79d7995877cd7a88ff691e98070 100644
--- a/activemodel/lib/active_model/validations/confirmation.rb
+++ b/activemodel/lib/active_model/validations/confirmation.rb
@@ -45,8 +45,9 @@ module HelperMethods
# Configuration options:
# * :message - A custom error message (default is: "doesn't match
# confirmation").
- # * :on - Specifies when this validation is active (default is
- # :nil, other options :create, :update).
+ # * :on - Specifies when this validation is active. Runs in all
+ # validation contexts by default (+nil+), other options are :create
+ # and :update.
# * :if - Specifies a method, proc or string to call to determine
# if the validation should occur (e.g. :if => :allow_validation,
# or :if => Proc.new { |user| user.signup_step > 2 }). The
diff --git a/activemodel/lib/active_model/validations/exclusion.rb b/activemodel/lib/active_model/validations/exclusion.rb
index 41388927860ba19fbe635d9875e6fb78c6ad6390..e38e565d096d10861efcb16d1c8711d8b1070543 100644
--- a/activemodel/lib/active_model/validations/exclusion.rb
+++ b/activemodel/lib/active_model/validations/exclusion.rb
@@ -29,6 +29,9 @@ module HelperMethods
# * :message - Specifies a custom error message (default is: "is reserved").
# * :allow_nil - If set to true, skips this validation if the attribute is +nil+ (default is +false+).
# * :allow_blank - If set to true, skips this validation if the attribute is blank (default is +false+).
+ # * :on - Specifies when this validation is active. Runs in all
+ # validation contexts by default (+nil+), other options are :create
+ # and :update.
# * :if - Specifies a method, proc or string to call to determine if the validation should
# occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }). The
# method, proc or string should return or evaluate to a true or false value.
diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb
index ca8920bce667279c375154b77cd61be260a9edf6..541f53a83441fa60265c7d9fb40d2faa14ddab1a 100644
--- a/activemodel/lib/active_model/validations/format.rb
+++ b/activemodel/lib/active_model/validations/format.rb
@@ -51,7 +51,9 @@ module HelperMethods
# * :allow_blank - If set to true, skips this validation if the attribute is blank (default is +false+).
# * :with - Regular expression that if the attribute matches will result in a successful validation.
# * :without - Regular expression that if the attribute does not match will result in a successful validation.
- # * :on - Specifies when this validation is active (default is nil, other options :create, :update).
+ # * :on - Specifies when this validation is active. Runs in all
+ # validation contexts by default (+nil+), other options are :create
+ # and :update.
# * :if - Specifies a method, proc or string to call to determine if the validation should
# occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }). The
# method, proc or string should return or evaluate to a true or false value.
diff --git a/activemodel/lib/active_model/validations/inclusion.rb b/activemodel/lib/active_model/validations/inclusion.rb
index 108586b8df7eadfea618f39f9da15503a1215447..7d4ccc0d4f0ef8c8afd6fd46ebc8ad1857a74859 100644
--- a/activemodel/lib/active_model/validations/inclusion.rb
+++ b/activemodel/lib/active_model/validations/inclusion.rb
@@ -46,6 +46,9 @@ module HelperMethods
# * :message - Specifies a custom error message (default is: "is not included in the list").
# * :allow_nil - If set to true, skips this validation if the attribute is +nil+ (default is +false+).
# * :allow_blank - If set to true, skips this validation if the attribute is blank (default is +false+).
+ # * :on - Specifies when this validation is active. Runs in all
+ # validation contexts by default (+nil+), other options are :create
+ # and :update.
# * :if - Specifies a method, proc or string to call to determine if the validation should
# occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }). The
# method, proc or string should return or evaluate to a true or false value.
diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb
index 97a5cb012e3bb15f6800e60cee228d31c8af90eb..7af6c83460f2217c3d717e11c1caa0bc496ba7a0 100644
--- a/activemodel/lib/active_model/validations/length.rb
+++ b/activemodel/lib/active_model/validations/length.rb
@@ -83,7 +83,9 @@ module HelperMethods
# * :too_short - The error message if the attribute goes under the minimum (default is: "is too short (min is %{count} characters)").
# * :wrong_length - The error message if using the :is method and the attribute is the wrong size (default is: "is the wrong length (should be %{count} characters)").
# * :message - The error message to use for a :minimum, :maximum, or :is violation. An alias of the appropriate too_long/too_short/wrong_length message.
- # * :on - Specifies the context where this validation is active (e.g. :on => :create or :on => :special_rules)
+ # * :on - Specifies when this validation is active. Runs in all
+ # validation contexts by default (+nil+), other options are :create
+ # and :update.
# * :if - Specifies a method, proc or string to call to determine if the validation should
# occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }). The
# method, proc or string should return or evaluate to a true or false value.
diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb
index 7b155bb7f79a7394ad1116d807b40991b327ea29..ae576462e682c767b0a69e4739a7fefd0cd3b174 100644
--- a/activemodel/lib/active_model/validations/numericality.rb
+++ b/activemodel/lib/active_model/validations/numericality.rb
@@ -93,7 +93,9 @@ module HelperMethods
#
# Configuration options:
# * :message - A custom error message (default is: "is not a number").
- # * :on - Specifies the context where this validation is active (e.g. :on => :create or :on => :special_rules)
+ # * :on - Specifies when this validation is active. Runs in all
+ # validation contexts by default (+nil+), other options are :create
+ # and :update.
# * :only_integer - Specifies whether the value has to be an integer, e.g. an integral value (default is +false+).
# * :allow_nil - Skip validation if attribute is +nil+ (default is +false+). Notice that for fixnum and float columns empty strings are converted to +nil+.
# * :greater_than - Specifies the value must be greater than the supplied value.
diff --git a/activemodel/lib/active_model/validations/presence.rb b/activemodel/lib/active_model/validations/presence.rb
index 3bfd6f15d18b314e4937aadfa4bbb1fb0d7b2333..cfb4c33dcc7cfe38134c878a89eafefa37311164 100644
--- a/activemodel/lib/active_model/validations/presence.rb
+++ b/activemodel/lib/active_model/validations/presence.rb
@@ -26,7 +26,9 @@ module HelperMethods
#
# Configuration options:
# * message - A custom error message (default is: "can't be blank").
- # * :on - Specifies the context where this validation is active (e.g. :on => :create or :on => :special_rules)
+ # * :on - Specifies when this validation is active. Runs in all
+ # validation contexts by default (+nil+), other options are :create
+ # and :update.
# * if - Specifies a method, proc or string to call to determine if the validation should
# occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }).
# The method, proc or string should return or evaluate to a true or false value.
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index 292de3ee619b92b7dbad38a08e20e7061335d403..d73fce9fd027d3a2de68d7a2db0bdbcba4408fb7 100644
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -20,7 +20,7 @@ def initialize(record)
# = Active Record Validations
#
- # Active Record includes the majority of its validations from ActiveModel::Validations
+ # Active Record includes the majority of its validations from ActiveModel::Validations
# all of which accept the :on argument to define the context where the
# validations are active. Active Record will always supply either the context of
# :create or :update dependent on whether the model is a
@@ -56,14 +56,14 @@ def save!(options={})
perform_validations(options) ? super : raise(RecordInvalid.new(self))
end
- # Runs all the specified validations and returns true if no errors were added otherwise false.
+ # Runs all the validations within the specified context. Returns true if no errors are found,
+ # false otherwise.
#
- # ==== Arguments
+ # If the argument is false (default is +nil+), the context is set to :create if
+ # new_record? is true, and to :update if it is not.
#
- # * context - Context to scope the execution of the validations. Default is nil.
- # If nil then the response of new_record? will determine the context. If new_record?
- # returns true the context will be :create, otherwise :update. Validation contexts
- # for each validation can be defined using the :on option
+ # Validations with no :on option will run no matter the context. Validations with
+ # some :on option will only run in the specified context.
def valid?(context = nil)
context ||= (new_record? ? :create : :update)
output = super(context)
diff --git a/activerecord/lib/active_record/validations/associated.rb b/activerecord/lib/active_record/validations/associated.rb
index 0f5f2a6e99ebc39b40c83156c6e2683ad39dcea4..3a783aeb000be81661bdb5cc6d8d295e1160c1b8 100644
--- a/activerecord/lib/active_record/validations/associated.rb
+++ b/activerecord/lib/active_record/validations/associated.rb
@@ -33,7 +33,9 @@ module ClassMethods
#
# Configuration options:
# * :message - A custom error message (default is: "is invalid")
- # * :on - Specifies when this validation is active (default is nil, other options :create, :update).
+ # * :on - Specifies when this validation is active. Runs in all
+ # validation contexts by default (+nil+), other options are :create
+ # and :update.
# * :if - Specifies a method, proc or string to call to determine if the validation should
# occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }). The
# method, proc or string should return or evaluate to a true or false value.