-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Exclude ActiveStorage attachments from tenancy #611
Comments
Also running into a similar problem: The model has an attachment using ActiveStorage
The model is excluded like so:
When switched onto a tenant DB, the logo is not available. When accessing from the public DB, the logo is attached. Is there a way to make ActiveStorage play nice with Apartment? |
Update: I was able to get things working by adding these two models to But this obviously means all ActiveStorage data is only on the "public" DB. |
I was wondering why |
In my app, some attachments should be tenanted and other should be public. User avatars for example should be public but attachments on tenanted resources should be tenanted. There's an inherent incompatibility between schemas and polymorphism. It should still work if you use If I call
While this is working:
This may have something to do with the way I'm including the attachment blob in the ActiveRecord::Relation but I don't see any issue with |
Feature request, or How To??
Steps to reproduce
Have an excluded model, add ActiveStorage to that model. Here, Teams have "Logos" and "Branded Backgrounds" which are, ideally, global. My Teams also act as the Tenants here, but the fixture list can be global, and the issue may stand alone.
config.excluded_models = %w{ User Order Team Fixture }
I've tried to exclude some variation of
ActiveStorage
/ActiveStorage::Attached
/ActiveStorage::Attached::One
but get aundefined method
establish_connection' for [x]` in response.Desired behavior
A Tenanted model's attachments should be globally accessible
Actual behavior
While the Tenant model is visible, adding an attachment either in the public domain or in a tenant, it displays no attachments for each of the other tenants. If this was Paperclip or some such I don't imagine there'd be an issue, but using Rail's Own Brand storage solution I can't work out the solution.
System configuration
Ruby 2.6.3
Rails 5.2
Apartment 2.2
DB: Sqlite locally/Mysql in production test
config/initializers/apartment.rb
or so):`Apartment.configure do |config|
config.excluded_models = %w{ User Order Team Fixture }
config.excluded_models << 'ActiveStorage::Attached::One'
config.tenant_names = lambda { Team.clients.pluck :tenant_identifier }
config.use_schemas = true
end`
The text was updated successfully, but these errors were encountered: