Exception: ActiveModel::ValidationError
- Defined in:
 - activemodel/lib/active_model/validations.rb
 
Overview
Active Model ValidationError
Raised by validate! when the model is invalid. Use the model method to retrieve the record which did not validate.
begin
  complex_operation_that_internally_calls_validate!
rescue ActiveModel::ValidationError => invalid
  puts invalid.model.errors
end
  Instance Attribute Summary collapse
- 
  
    
      #model  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute model.
 
Instance Method Summary collapse
- 
  
    
      #initialize(model)  ⇒ ValidationError 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of ValidationError.
 
Constructor Details
#initialize(model) ⇒ ValidationError
Returns a new instance of ValidationError.
      496 497 498 499 500  | 
    
      # File 'activemodel/lib/active_model/validations.rb', line 496 def initialize(model) @model = model errors = @model.errors..join(", ") super(I18n.t(:"#{@model.class.i18n_scope}.errors.messages.model_invalid", errors: errors, default: :"errors.messages.model_invalid")) end  | 
  
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
      494 495 496  | 
    
      # File 'activemodel/lib/active_model/validations.rb', line 494 def model @model end  |