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

Fix setting custom preview_paths #2182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
6 changes: 3 additions & 3 deletions lib/view_component/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading