Last active
August 19, 2020 17:32
-
-
Save Syntaf/a40223be1cb4b44e2a0481ce127faf3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/application_controller.rb | |
class ApplicationController < ActionController::Base | |
# ... | |
def reload_admin | |
RailsAdmin::Config.reset | |
load(Rails.root.join('config/initializers/rails_admin.rb')) | |
# define all models with concerns to be reloaded | |
models = %w[User Group] | |
models.each do |m| | |
# remove model definition | |
Object.send(:remove_const, m) | |
# generate file_path and reload model | |
model_file_path = m.to_s.underscore | |
load(Rails.root.join("app/models/#{model_file_path}.rb")) | |
end | |
end | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment