diff --git a/app/controllers/concerns/exception_handler.rb b/app/controllers/concerns/exception_handler.rb index d5b9bfff..a47278db 100644 --- a/app/controllers/concerns/exception_handler.rb +++ b/app/controllers/concerns/exception_handler.rb @@ -10,8 +10,9 @@ module ExceptionHandler included do rescue_from SiteNotFound, with: :site_not_found rescue_from PageNotFound, with: :page_not_found - rescue_from Pundit::NotAuthorizedError, with: :page_not_found - rescue_from Pundit::Error, with: :page_unauthorized + rescue_from Pundit::Error, with: :page_not_found + rescue_from Pundit::NotAuthorizedError, with: :page_unauthorized + rescue_from Pundit::NilPolicyError, with: :page_not_found rescue_from ActionController::RoutingError, with: :page_not_found rescue_from ActionController::ParameterMissing, with: :page_not_found end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 4aa2c8d0..7974d317 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -15,6 +15,8 @@ class PostsController < ApplicationController # Las URLs siempre llevan el idioma actual o el de le usuarie def default_url_options { locale: locale } + rescue SiteNotFound + {} end # @todo Mover a tu propio scope diff --git a/app/controllers/usuaries_controller.rb b/app/controllers/usuaries_controller.rb index 6924c860..cba349c5 100644 --- a/app/controllers/usuaries_controller.rb +++ b/app/controllers/usuaries_controller.rb @@ -29,7 +29,7 @@ class UsuariesController < ApplicationController @usuarie = Usuarie.find(params[:id]) - if @site.usuaries.count > 1 + if @site.invitade?(@usuarie) || @site.usuaries.count > 1 # Mágicamente elimina el rol @usuarie.sites.delete(@site) else