From e89c156ff4a919565cf5561234ce55bf82f34814 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 17 Jun 2020 10:40:59 -0300 Subject: [PATCH] no generar excepciones en rutas inexistentes --- app/controllers/api/v1/base_controller.rb | 7 +++++++ app/controllers/application_controller.rb | 2 ++ 2 files changed, 9 insertions(+) diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb index de58c343..48368d31 100644 --- a/app/controllers/api/v1/base_controller.rb +++ b/app/controllers/api/v1/base_controller.rb @@ -7,6 +7,8 @@ module Api protect_from_forgery with: :null_session respond_to :json + rescue_from ActionController::RoutingError, with: :page_not_found + private # Realiza la inversa de Site#hostname @@ -31,6 +33,11 @@ module Api def default_site Site.first end + + # Muestra una página 404 + def page_not_found + render 'application/page_not_found', status: :not_found + end end end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c7a5dc56..17dc49a2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,6 +8,8 @@ class ApplicationController < ActionController::Base before_action :configure_permitted_parameters, if: :devise_controller? around_action :set_locale + rescue_from ActionController::RoutingError, with: :page_not_found + before_action do Rack::MiniProfiler.authorize_request if current_usuarie.try(:ends_with?, '@' + ENV.fetch('SUTTY', 'sutty.nl')) end