Мы обычно примерно так делаем. Добавляем методы в базовый контроллер
def respond_with_400(exception)
render json: { success: false, all_errors: ['The user has not authorized application'] }, status: 400
end
def respond_with_404(exception=nil)
render json: { success: false, all_errors: [t('errors.not_found')] }, status: 404
end
def respond_with_500(exception)
render json: {success: false, all_errors: [t('errors.something_went_wrong')], debug: exception.to_s}, status: 500
end
def respond_with_success(resource=nil, status=200)
result = {success: true}
result.merge!(:"#{resource.class.name.underscore}" => {id: resource.id}) if resource.present?
render json: result, status: status
end
def respond_with_errors(resource=nil, status=422, debug=nil)
result = {success: false}
result.merge!(errors: resource.errors.messages, all_errors: resource.errors.full_messages) if resource.present?
result.merge!(debug: debug) if debug.present?
render json: result, status: status
end