I have a rails app with multi-tenancy implemented using apartment gem. I have a model called Report that is excluded from multi-tenancy, i.e it is common to all tenants.
# app/models/report.rb
class Report < ApplicationRecord
has_one_attached :file
...
end
# config/initializers/apartment.rb
Apartment.configure do |config|
config.excluded_models = %w{ Tenant User Report }
...
end
In ReportsController:
...
def upload
@record = Report.find(params[:report_id])
record.file.attach(params[:file])
head 200
end
...
When I upload the file, active_storage updates only the schema that is valid for the current tenant. But since the Report model is tenant agnostic, I want the attached files to be tenant agnostic as well.
Is there any way to add active_storage tables in excluded models list/schema?