Module: Caprese::Errors

Extended by:
ActiveSupport::Concern
Included in:
Controller
Defined in:
lib/caprese/controller/concerns/errors.rb

Instance Method Summary collapse

Instance Method Details

#error(field: nil, code: :invalid, t: {}) ⇒ Object

Fail with a controller action error

Parameters:

  • field (Symbol) (defaults to: nil)

    the field (a controller param) that caused the error

  • code (Symbol) (defaults to: :invalid)

    the code for the error

  • t (Hash) (defaults to: {})

    the interpolation params to be passed into I18n.t



29
30
31
32
33
34
35
36
37
# File 'lib/caprese/controller/concerns/errors.rb', line 29

def error(field: nil, code: :invalid, t: {})
  Error.new(
    controller: unnamespace(params[:controller]),
    action: params[:action],
    field: field,
    code: code,
    t: t
  )
end