validates_presence_of

validates_presence_of(*attr_names) Instance Public methods Validates that the specified attributes are not blank (as defined by Object#blank?), and, if the attribute is an association, that the associated object is not marked for destruction. Happens by default on save. class Person < ActiveRecord::Base has_one :face validates_presence_of :face end The face attribute must be in the object and it cannot be blank or marked for destruction. If you want to validate the presence

validates_uniqueness_of

validates_uniqueness_of(*attr_names) Instance Public methods Validates whether the value of the specified attributes are unique across the system. Useful for making sure that only one user can be named âdavidhhâ. class Person < ActiveRecord::Base validates_uniqueness_of :user_name end It can also validate whether the value of the specified attributes are unique based on a :scope parameter: class Person < ActiveRecord::Base validates_uniqueness_of :user_name, scope: :acco

save

save(options={}) Instance Public methods The validation process on save can be skipped by passing validate: false. The regular #save method is replaced with this when the validations module is mixed in, which it is by default.

save!

save!(options={}) Instance Public methods Attempts to save the record just like #save but will raise a RecordInvalid exception instead of returning false if the record is not valid.

valid?

valid?(context = nil) Instance Public methods Runs all the validations within the specified context. Returns true if no errors are found, false otherwise. 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. Validations with no :on option will run no matter the context. Validations with some :on option will only run in the specified context.

eager_load!

eager_load!() Class Public methods

gem_version

gem_version() Class Public methods Returns the version of the currently loaded ActiveRecord as a Gem::Version

new

new() Class Public methods

version

version() Class Public methods Returns the version of the currently loaded ActiveRecord as a Gem::Version

test_crazy_object

test_crazy_object() Instance Public methods