module ActiveRecord::Validations
def perform_validations(options={}) # :nodoc:
def perform_validations(options={}) # :nodoc: options[:validate] == false || valid?(options[:context]) end
def save(options={})
The regular Base#save method is replaced with this when the validations
The validation process on save can be skipped by passing validate: false.
def save(options={}) perform_validations(options) ? super : false end
def save!(options={})
Attempts to save the record just like Base#save but will raise a +RecordInvalid+
def save!(options={}) perform_validations(options) ? super : raise(RecordInvalid.new(self)) end
def valid?(context = nil)
Validations with no :on option will run no matter the context. Validations with
new_record? is +true+, and to :update if it is not.
If the argument is +false+ (default is +nil+), the context is set to :create if
no errors are found, +false+ otherwise.
Runs all the validations within the specified context. Returns +true+ if
def valid?(context = nil) context ||= (new_record? ? :create : :update) output = super(context) errors.empty? && output end