Methods
Included Modules
Public Instance methods
save(options={})

The validation process on save can be skipped by passing false. The regular Base#save method is replaced with this when the validations module is mixed in, which it is by default.

      # File activerecord/lib/active_record/validations.rb, line 42
42:     def save(options={})
43:       perform_validations(options) ? super : false
44:     end
save!(options={})

Attempts to save the record just like Base#save but will raise a RecordInvalid exception instead of returning false if the record is not valid.

      # File activerecord/lib/active_record/validations.rb, line 48
48:     def save!(options={})
49:       perform_validations(options) ? super : raise(RecordInvalid.new(self))
50:     end
valid?(context = nil)

Runs all the specified validations and returns true if no errors were added otherwise false.

      # File activerecord/lib/active_record/validations.rb, line 53
53:     def valid?(context = nil)
54:       context ||= (new_record? ? :create : :update)
55:       output = super(context)
56: 
57:       deprecated_callback_method(:validate)
58:       deprecated_callback_method(:"validate_on_#{context}")
59: 
60:       errors.empty? && output
61:     end
Protected Instance methods
perform_validations(options={})
      # File activerecord/lib/active_record/validations.rb, line 65
65:     def perform_validations(options={})
66:       perform_validation = case options
67:       when Hash
68:         options[:validate] != false
69:       else
70:         ActiveSupport::Deprecation.warn "save(#{options}) is deprecated, please give save(:validate => #{options}) instead", caller
71:         options
72:       end
73: 
74:       if perform_validation
75:         valid?(options.is_a?(Hash) ? options[:context] : nil)
76:       else
77:         true
78:       end
79:     end