Module: TopModel::Validations::ClassMethods
- Defined in:
- lib/topmodel/validations/uniqueness.rb
Instance Method Summary collapse
- 
  
    
      #validates_uniqueness_of(*attr_names)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Validates that the specified attribute is unique. 
Instance Method Details
#validates_uniqueness_of(*attr_names) ⇒ Object
Validates that the specified attribute is unique.
class Person < ActiveRecord::Base
  validates_uniquness_of :essay
end
Configuration options:
- 
:allow_nil- Attribute may benil; skip validation.
- 
:allow_blank- Attribute may be blank; skip validation.
- 
:message- The error message to use for a:minimum,:maximum, or:isviolation. An alias of the appropriatetoo_long/too_short/wrong_lengthmessage.
- 
:on- Specifies when this validation is active (default is:save, other options:create,: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.
- 
:unless- Specifies a method, proc or string to call to determine if the validation should not occur (e.g.:unless => :skip_validation, or:unless => Proc.new { |user| user.signup_step <= 2 }). The method, proc or string should return or evaluate to a true or false value.
| 35 36 37 | # File 'lib/topmodel/validations/uniqueness.rb', line 35 def validates_uniqueness_of(*attr_names) validates_with UniquenessValidator, _merge_attributes(attr_names) end |