@@ -43,7 +43,8 @@ class Engine < ::Rails::Engine
4343 engine_name 'better_together'
4444 isolate_namespace BetterTogether
4545
46- config . autoload_paths += Dir [ "#{ config . root } /lib/better_together/**/" ]
46+ # Avoid modifying frozen autoload path arrays (Rails 8 compatibility)
47+ config . autoload_paths = Array ( config . autoload_paths ) + Dir [ "#{ root } /lib/better_together/**/" ]
4748
4849 config . generators do |g |
4950 g . orm :active_record , primary_key_type : :uuid
@@ -81,8 +82,9 @@ class Engine < ::Rails::Engine
8182 initializer 'better_together.action_mailer' do |app |
8283 if Rails . env . development?
8384 app . config . action_mailer . show_previews = true
84- app . config . action_mailer . preview_paths = app . config . action_mailer . preview_paths +
85- [ BetterTogether ::Engine . root . join ( 'spec/mailers/previews' ) ]
85+ app . config . action_mailer . preview_paths =
86+ app . config . action_mailer . preview_paths . to_a +
87+ [ BetterTogether ::Engine . root . join ( 'spec/mailers/previews' ) ]
8688 else
8789 app . config . action_mailer . show_previews = false
8890 end
@@ -91,12 +93,15 @@ class Engine < ::Rails::Engine
9193 # Add engine manifest to precompile assets in production
9294 initializer 'better_together.assets' do |app |
9395 # Ensure we are not modifying frozen arrays
94- app . config . assets . precompile += %w[ better_together_manifest.js ]
95- app . config . assets . paths = [ root . join ( 'app' , 'assets' , 'images' ) ,
96- root . join ( 'app' , 'javascript' ) ,
97- root . join ( 'vendor' , 'javascript' ) ,
98- root . join ( 'vendor' , 'stylesheets' ) ,
99- root . join ( 'vendor' , 'javascripts' ) ] + app . config . assets . paths . to_a
96+ app . config . assets . precompile =
97+ app . config . assets . precompile . to_a + %w[ better_together_manifest.js ]
98+ app . config . assets . paths =
99+ app . config . assets . paths . to_a +
100+ [ root . join ( 'app' , 'assets' , 'images' ) ,
101+ root . join ( 'app' , 'javascript' ) ,
102+ root . join ( 'vendor' , 'javascript' ) ,
103+ root . join ( 'vendor' , 'stylesheets' ) ,
104+ root . join ( 'vendor' , 'javascripts' ) ]
100105 end
101106
102107 initializer 'better_together.i18n' do |app |
@@ -107,9 +112,11 @@ class Engine < ::Rails::Engine
107112
108113 initializer 'better_together.importmap' , before : 'importmap' do |app |
109114 # Ensure we are not modifying frozen arrays
110- app . config . importmap . paths = [ Engine . root . join ( 'config/importmap.rb' ) ] + app . config . importmap . paths . to_a
111- app . config . importmap . cache_sweepers = [ root . join ( 'app/assets/javascripts' ) ,
112- root . join ( 'app/javascript' ) ] + app . config . importmap . cache_sweepers . to_a
115+ app . config . importmap . paths =
116+ app . config . importmap . paths . to_a + [ Engine . root . join ( 'config/importmap.rb' ) ]
117+ app . config . importmap . cache_sweepers =
118+ app . config . importmap . cache_sweepers . to_a +
119+ [ root . join ( 'app/assets/javascripts' ) , root . join ( 'app/javascript' ) ]
113120 end
114121
115122 initializer 'better_together.importmap.pins' , after : 'importmap' do |app |
0 commit comments