Skip to content

Commit 259b08b

Browse files
committed
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.
1 parent 608c1bf commit 259b08b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

actiontext/lib/generators/action_text/install/install_generator.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ def create_actiontext_files
6262
def enable_image_processing_gem
6363
if (gemfile_path = Pathname(destination_root).join("Gemfile")).exist?
6464
say "Ensure image_processing gem has been enabled so image uploads will work (remember to bundle!)"
65-
uncomment_lines gemfile_path, /gem "image_processing"/
65+
image_processing_regex = /gem ["']image_processing["']/
66+
if File.readlines(gemfile_path).grep(image_processing_regex).any?
67+
uncomment_lines gemfile_path, image_processing_regex
68+
else
69+
run "bundle add --skip-install image_processing"
70+
end
6671
end
6772
end
6873

0 commit comments

Comments
 (0)