ErwinM / acts_as_tenant

Easy multi-tenancy for Rails in a shared database setup.
MIT License
1.53k stars 262 forks source link

User can access everything (admin) #298

Closed lucasazuma closed 1 year ago

lucasazuma commented 1 year ago

I have a problem with creating and updating in my controller.In my website users have roles, everybody BUT the admin belongs to a county, so my tenant is defined by the county. When I try to create or update an instance who has the act_as tenant i need to define a county, i wanna know which is better, using a before_action in the create and update methods in, or using a before_create in the model, in order to set the current_tenant

fidalgo commented 1 year ago

Isn't this a case to use without_tenant

ActsAsTenant.without_tenant do
  # Tenant checking is disabled for all code in this block
end

as mentioned here: https://github.com/ErwinM/acts_as_tenant#disabling-tenant-checking-for-a-block