Skip to content

Instantly share code, notes, and snippets.

View jramiresbrito's full-sized avatar
🎯
Focusing

João Victor Ramires Guimarães Brito jramiresbrito

🎯
Focusing
View GitHub Profile
@jramiresbrito
jramiresbrito / api_controller.rb
Created November 28, 2020 09:53
Request test for Category
module Admin::V1
class ApiController < ApplicationController
include Authenticable
def render_error(message: nil, fields: nil, status: :unprocessable_entity)
errors = {}
errors['fields'] = fields if fields.present?
errors['message'] = message if message.present?
render json: { errors: errors }, status: status