module Caprese::Errors
Public Instance Methods
error(field: nil, code: :invalid, t: {})
click to toggle source
Fail with a controller action error
@param [Symbol] field the field (a controller param) that caused the error @param [Symbol] code the code for the error @param [Hash] t the interpolation params to be passed into I18n.t
# 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
Private Instance Methods
enable_caprese_style_errors() { || ... }
click to toggle source
Temporarily render model errors as Caprese::Record::Errors
instead of ActiveModel::Errors
# File lib/caprese/controller/concerns/errors.rb, line 42 def enable_caprese_style_errors Caprese::Record.caprese_style_errors = true yield Caprese::Record.caprese_style_errors = false end