From 517e9a70592e37d9212db5d65b1b306d4d7aa3c2 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Tue, 15 Nov 2016 05:35:13 +0000 Subject: [PATCH] Load models from eager_load, not autoload_paths If something is in `autoload_paths`, it doesn't mean it can or should *always* be loaded. Rails explicitly makes this distinction with `eager_load`. E.g. if I'm developing a Rails engine, I might want to add `lib` to autoload paths (to ease the development of the engine), but that doesn't mean I want to eagerly load ruby files in `lib/generators/templates`! Resolves #2770 --- lib/rails_admin/config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rails_admin/config.rb b/lib/rails_admin/config.rb index 2f185a02bb..44efd75f3c 100644 --- a/lib/rails_admin/config.rb +++ b/lib/rails_admin/config.rb @@ -323,7 +323,7 @@ def viable_models included_models.collect(&:to_s).presence || begin @@system_models ||= # memoization for tests ([Rails.application] + Rails::Engine.subclasses.collect(&:instance)).flat_map do |app| - (app.paths['app/models'].to_a + app.config.autoload_paths).collect do |load_path| + (app.paths['app/models'].to_a + app.paths.eager_load).collect do |load_path| Dir.glob(app.root.join(load_path)).collect do |load_dir| Dir.glob(load_dir + '/**/*.rb').collect do |filename| # app/models/module/class.rb => module/class.rb => module/class => Module::Class