5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 02:11:42 +00:00

volver a los sitios si el sitio no se encuentra

This commit is contained in:
f 2019-07-10 19:07:39 -03:00
parent 1fd0649993
commit c45446f40a
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
2 changed files with 24 additions and 3 deletions

View file

@ -2,6 +2,8 @@
# Forma de ingreso a Sutty
class ApplicationController < ActionController::Base
include ExceptionHandler
protect_from_forgery with: :exception
before_action :set_locale
@ -17,10 +19,13 @@ class ApplicationController < ActionController::Base
# Encontrar un sitio por su nombre
def find_site
current_usuarie.sites.find_by_name(params[:site_id] || params[:id])
id = params[:site_id] || params[:id]
# TODO: reenviar a un 403 si el sitio ya no está permitido para le
# usuarie
unless (site = current_usuarie.sites.find_by_name(id))
raise SiteNotFound
end
site
end
def find_post(site)

View file

@ -0,0 +1,16 @@
# frozen_string_literal: true
# Gestiona las excepciones que lanzamos desde los controladores
module ExceptionHandler
extend ActiveSupport::Concern
class SiteNotFound < StandardError; end
included do
rescue_from SiteNotFound, with: :site_not_found
end
def site_not_found
redirect_to sites_path
end
end