From b481574a33764e2db1caf01c233a9c9ac9723780 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 21 Feb 2011 11:37:08 +0100 Subject: copy-edits 8d96b89 --- activerecord/lib/active_record/validations.rb | 14 +++++++------- activerecord/lib/active_record/validations/associated.rb | 4 +++- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 292de3ee61..d73fce9fd0 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -20,7 +20,7 @@ module ActiveRecord # = 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 @@ module ActiveRecord 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 0f5f2a6e99..3a783aeb00 100644 --- a/activerecord/lib/active_record/validations/associated.rb +++ b/activerecord/lib/active_record/validations/associated.rb @@ -33,7 +33,9 @@ module ActiveRecord # # 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. -- cgit v1.2.3