diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 9760606aa..810c6781a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,10 @@ nav_order: 5 ## main +* Fix setting custom `preview_paths`. + + *Thomas von Deyen* + * Add FreeATS to list of companies using ViewComponent. *Ilia Liamshin* diff --git a/lib/view_component/engine.rb b/lib/view_component/engine.rb index b920eb5d8..0a8fb5887 100644 --- a/lib/view_component/engine.rb +++ b/lib/view_component/engine.rb @@ -76,12 +76,12 @@ class Engine < Rails::Engine # :nodoc: end # :nocov: - initializer "view_component.set_autoload_paths" do |app| + initializer "view_component.set_autoload_paths", before: :set_autoload_paths do |app| options = app.config.view_component if options.show_previews && !options.preview_paths.empty? - paths_to_add = options.preview_paths - ActiveSupport::Dependencies.autoload_paths - ActiveSupport::Dependencies.autoload_paths.concat(paths_to_add) if paths_to_add.any? + paths_to_add = options.preview_paths - app.config.autoload_paths + app.config.autoload_paths.concat(paths_to_add) if paths_to_add.any? end end