From 259b08b088184016e2e6d550de3a424cfab5dc83 Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Fri, 8 Mar 2024 12:37:06 +0000 Subject: [PATCH] Ensure image_processing is installed with Trix Currently if the Gemfile does not contain a commented out line for image_processing, or the line uses single, not double quotes, image_processing will not be installed and Trix will not be able to correctly handle image attachments. This ensures image_processing _is_ installed in those circumstances. --- .../generators/action_text/install/install_generator.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/actiontext/lib/generators/action_text/install/install_generator.rb b/actiontext/lib/generators/action_text/install/install_generator.rb index 03057ea3cfe..b045f66640b 100644 --- a/actiontext/lib/generators/action_text/install/install_generator.rb +++ b/actiontext/lib/generators/action_text/install/install_generator.rb @@ -62,7 +62,12 @@ module ActionText def enable_image_processing_gem if (gemfile_path = Pathname(destination_root).join("Gemfile")).exist? say "Ensure image_processing gem has been enabled so image uploads will work (remember to bundle!)" - uncomment_lines gemfile_path, /gem "image_processing"/ + image_processing_regex = /gem ["']image_processing["']/ + if File.readlines(gemfile_path).grep(image_processing_regex).any? + uncomment_lines gemfile_path, image_processing_regex + else + run "bundle add --skip-install image_processing" + end end end