You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my app, I'm attempting to manage which models are excluded by customer, which I'm doing with a decorator (see below):
RailsAdmin::ApplicationController.class_eval do
before_action :switch_tenant, :reload_rails_admin
def switch_tenant
Apartment::Tenant.switch!(params[:customer_id])
end
def reload_rails_admin
Rails.application.eager_load!
excluded_models = ApplicationRecord.descendants.map { |m| m.name unless m.base_class.table_exists? }.compact
puts "Excluded models: #{excluded_models}"
RailsAdmin::Config.reset
RailsAdmin.config do |config|
config.excluded_models = excluded_models
config.actions do
dashboard
index
new
export
bulk_delete
show
edit
delete
show_in_app
end
end
end
end
What I've found is that the RailsAdmin config is sticky. Depending on which customer I load first, that's the set of models that are used for the next customer. At first, I thought maybe it was a caching thing (maybe it still is?), but I've attempted to insert Rails.cache.clear calls at various stages to no effect.
Any thoughts?
The text was updated successfully, but these errors were encountered:
In my app, I'm attempting to manage which models are excluded by customer, which I'm doing with a decorator (see below):
What I've found is that the RailsAdmin config is sticky. Depending on which customer I load first, that's the set of models that are used for the next customer. At first, I thought maybe it was a caching thing (maybe it still is?), but I've attempted to insert Rails.cache.clear calls at various stages to no effect.
Any thoughts?
The text was updated successfully, but these errors were encountered: