Skip to content

Commit 51fd83a

Browse files
authored
Merge pull request #205 from trinitytakei/adding-autoload_paths-should-not-trip-up-brakeman
Change the way autoload paths are added to application.rb
2 parents 5d536eb + d0531f9 commit 51fd83a

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

lib/generators/phlex/install/install_generator.rb

+9-21
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,22 @@ class InstallGenerator < ::Rails::Generators::Base
66

77
APPLICATION_CONFIGURATION_PATH = Rails.root.join("config/application.rb")
88
TAILWIND_CONFIGURATION_PATH = Rails.root.join("tailwind.config.js")
9+
ADD_EXTRA_AUTOLOAD_PATHS_CODE = <<-ADD_EXTRA_AUTOLOAD_PATHS_CODE
10+
config.autoload_paths.push(
11+
"\#{root}/app/views/components",
12+
"\#{root}/app/views",
13+
"\#{root}/app/views/layouts"
14+
)
915
10-
def autoload_components
11-
return unless APPLICATION_CONFIGURATION_PATH.exist?
12-
13-
inject_into_class(
14-
APPLICATION_CONFIGURATION_PATH,
15-
"Application",
16-
%( config.autoload_paths << "\#{root}/app/views/components"\n),
17-
)
18-
end
19-
20-
def autoload_layouts
21-
return unless APPLICATION_CONFIGURATION_PATH.exist?
22-
23-
inject_into_class(
24-
APPLICATION_CONFIGURATION_PATH,
25-
"Application",
26-
%( config.autoload_paths << "\#{root}/app/views/layouts"\n),
27-
)
28-
end
16+
ADD_EXTRA_AUTOLOAD_PATHS_CODE
2917

30-
def autoload_views
18+
def autoload_components_layouts_views
3119
return unless APPLICATION_CONFIGURATION_PATH.exist?
3220

3321
inject_into_class(
3422
APPLICATION_CONFIGURATION_PATH,
3523
"Application",
36-
%( config.autoload_paths << "\#{root}/app/views"\n),
24+
ADD_EXTRA_AUTOLOAD_PATHS_CODE,
3725
)
3826
end
3927

0 commit comments

Comments
 (0)