Configure current tenant in a before_action of the ApplicationController

This commit is contained in:
Manuel Bustillo 2024-11-30 21:11:25 +01:00
parent 63bb32f2a7
commit be3497ad64

View File

@ -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')