From be3497ad646ac9a86ff37d71b6e69b27a884369e Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Sat, 30 Nov 2024 21:11:25 +0100 Subject: [PATCH] Configure current tenant in a before_action of the ApplicationController --- app/controllers/application_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0d2a0c7..13400e3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,7 @@ # Copyright (C) 2024 Manuel Bustillo class ApplicationController < ActionController::Base + before_action :set_tenant before_action :authenticate_user! after_action :set_csrf_cookie @@ -29,6 +30,10 @@ class ApplicationController < ActionController::Base private + def set_tenant + ActsAsTenant.current_tenant = Wedding.find_by(slug: params[:slug]) + end + def development_swagger? Rails.env.test? || Rails.env.development? && request.headers['referer']&.include?('/api-docs/index.html')