From d0531f9138d3500fa2c5f80098cb7ac4f1c3bc6a Mon Sep 17 00:00:00 2001 From: Trinity Takei Date: Thu, 27 Jun 2024 21:00:38 +0200 Subject: [PATCH] Change the way autoload paths are added to application.rb --- .../phlex/install/install_generator.rb | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/lib/generators/phlex/install/install_generator.rb b/lib/generators/phlex/install/install_generator.rb index ecbd734..e0848ef 100644 --- a/lib/generators/phlex/install/install_generator.rb +++ b/lib/generators/phlex/install/install_generator.rb @@ -6,34 +6,22 @@ class InstallGenerator < ::Rails::Generators::Base APPLICATION_CONFIGURATION_PATH = Rails.root.join("config/application.rb") TAILWIND_CONFIGURATION_PATH = Rails.root.join("tailwind.config.js") + ADD_EXTRA_AUTOLOAD_PATHS_CODE = <<-ADD_EXTRA_AUTOLOAD_PATHS_CODE + config.autoload_paths.push( + "\#{root}/app/views/components", + "\#{root}/app/views", + "\#{root}/app/views/layouts" + ) - def autoload_components - return unless APPLICATION_CONFIGURATION_PATH.exist? - - inject_into_class( - APPLICATION_CONFIGURATION_PATH, - "Application", - %( config.autoload_paths << "\#{root}/app/views/components"\n), - ) - end - - def autoload_layouts - return unless APPLICATION_CONFIGURATION_PATH.exist? - - inject_into_class( - APPLICATION_CONFIGURATION_PATH, - "Application", - %( config.autoload_paths << "\#{root}/app/views/layouts"\n), - ) - end + ADD_EXTRA_AUTOLOAD_PATHS_CODE - def autoload_views + def autoload_components_layouts_views return unless APPLICATION_CONFIGURATION_PATH.exist? inject_into_class( APPLICATION_CONFIGURATION_PATH, "Application", - %( config.autoload_paths << "\#{root}/app/views"\n), + ADD_EXTRA_AUTOLOAD_PATHS_CODE, ) end