Skip to content

Commit 517e9a7

Browse files
authored
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
1 parent 9e1c66e commit 517e9a7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/rails_admin/config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def viable_models
323323
included_models.collect(&:to_s).presence || begin
324324
@@system_models ||= # memoization for tests
325325
([Rails.application] + Rails::Engine.subclasses.collect(&:instance)).flat_map do |app|
326-
(app.paths['app/models'].to_a + app.config.autoload_paths).collect do |load_path|
326+
(app.paths['app/models'].to_a + app.paths.eager_load).collect do |load_path|
327327
Dir.glob(app.root.join(load_path)).collect do |load_dir|
328328
Dir.glob(load_dir + '/**/*.rb').collect do |filename|
329329
# app/models/module/class.rb => module/class.rb => module/class => Module::Class

0 commit comments

Comments
 (0)