From 3fca449461aa1649ac874c39c36b56850f4f2efa Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Mon, 2 Dec 2024 09:04:48 +0100 Subject: [PATCH] Limit visibility per tenant --- app/controllers/application_controller.rb | 3 ++- db/seeds.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 15a4b17..8343f65 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 + set_current_tenant_through_filter before_action :set_tenant before_action :authenticate_user! after_action :set_csrf_cookie @@ -47,7 +48,7 @@ class ApplicationController < ActionController::Base end def set_tenant - ActsAsTenant.current_tenant = Wedding.find_by(slug: params[:slug]) + set_current_tenant(Wedding.find_by!(slug: params[:slug])) end def development_swagger? diff --git a/db/seeds.rb b/db/seeds.rb index e0a11a6..9d93073 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -9,9 +9,10 @@ ActsAsTenant.without_tenant do Group.delete_all Wedding.delete_all - wedding = Wedding.create!(slug: :default, date: 1.year.from_now) end +wedding = Wedding.create!(slug: :default, date: 1.year.from_now) + ActsAsTenant.with_tenant(wedding) do Expense.create!(name: 'Photographer', amount: 3000, pricing_type: 'fixed') Expense.create!(name: 'Country house', amount: 6000, pricing_type: 'fixed')