Merge pull request 'fix-tenant-scope' (#159) from fix-tenant-scope into main
Reviewed-on: #159
This commit is contained in:
commit
e0a34df7b7
@ -1,6 +1,7 @@
|
|||||||
# Copyright (C) 2024 Manuel Bustillo
|
# Copyright (C) 2024 Manuel Bustillo
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
|
set_current_tenant_through_filter
|
||||||
before_action :set_tenant
|
before_action :set_tenant
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
after_action :set_csrf_cookie
|
after_action :set_csrf_cookie
|
||||||
@ -47,7 +48,7 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_tenant
|
def set_tenant
|
||||||
ActsAsTenant.current_tenant = Wedding.find_by(slug: params[:slug])
|
set_current_tenant(Wedding.find_by!(slug: params[:slug]))
|
||||||
end
|
end
|
||||||
|
|
||||||
def development_swagger?
|
def development_swagger?
|
||||||
|
5
config/initializers/acts_as_tenant.rb
Normal file
5
config/initializers/acts_as_tenant.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Copyright (C) 2024 Manuel Bustillo
|
||||||
|
|
||||||
|
ActsAsTenant.configure do |config|
|
||||||
|
config.require_tenant = !Rails.env.test?
|
||||||
|
end
|
@ -2,12 +2,15 @@
|
|||||||
|
|
||||||
NUMBER_OF_GUESTS = 50
|
NUMBER_OF_GUESTS = 50
|
||||||
|
|
||||||
|
ActsAsTenant.without_tenant do
|
||||||
TablesArrangement.delete_all
|
TablesArrangement.delete_all
|
||||||
Expense.delete_all
|
Expense.delete_all
|
||||||
Guest.delete_all
|
Guest.delete_all
|
||||||
Group.delete_all
|
Group.delete_all
|
||||||
|
|
||||||
Wedding.delete_all
|
Wedding.delete_all
|
||||||
|
end
|
||||||
|
|
||||||
wedding = Wedding.create!(slug: :default, date: 1.year.from_now)
|
wedding = Wedding.create!(slug: :default, date: 1.year.from_now)
|
||||||
|
|
||||||
ActsAsTenant.with_tenant(wedding) do
|
ActsAsTenant.with_tenant(wedding) do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user