Exception: Granite::Form::ValidationError

Inherits:
Error
  • Object
show all
Defined in:
lib/granite/form/errors.rb

Overview

Backported from active_model 5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ ValidationError

Returns a new instance of ValidationError.



13
14
15
16
17
18
# File 'lib/granite/form/errors.rb', line 13

def initialize(model)
  @model = model
  errors = @model.errors.full_messages.join(', ')
  super(I18n.t(:"#{@model.class.i18n_scope}.errors.messages.model_invalid",
               errors: errors, default: :'errors.messages.model_invalid'))
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



11
12
13
# File 'lib/granite/form/errors.rb', line 11

def model
  @model
end