Method: ApiGuard::ResponseFormatters::Renderer#render_error

Defined in:
lib/api_guard/response_formatters/renderer.rb

#render_error(status, options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/api_guard/response_formatters/renderer.rb', line 14

def render_error(status, options = {})
  data = { status: I18n.t('api_guard.response.error') }
  data[:error] = options[:object] ? options[:object].errors.full_messages[0] : options[:message]

  render json: data, status: status
end