Skip to content
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

RailsAdmin::Config.reset does not fully reset config #3305

Closed
adambruss opened this issue Sep 9, 2020 · 3 comments
Closed

RailsAdmin::Config.reset does not fully reset config #3305

adambruss opened this issue Sep 9, 2020 · 3 comments
Milestone

Comments

@adambruss
Copy link

adambruss commented Sep 9, 2020

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?

@grillermo
Copy link

Yeah, you need to reload the server each time you change this config. It is the same with all initializers.

@computeus
Copy link

I have the same exact problem. No matter what I tried, I am not able to make the changes to included_models option work.

When I print the included_models option value, it seems it is changed but it doesn't affect the frontend.

@mshibuya mshibuya added this to the 3.0.0 milestone Aug 8, 2021
@mshibuya
Copy link
Member

mshibuya commented Aug 8, 2021

Yeah this is not ideal, I'll take a look into this to see if it's fixable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants