Skip to content

Commit

Permalink
Ensure image_processing is installed with Trix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tsvallender committed Mar 8, 2024
1 parent 608c1bf commit 259b08b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ def create_actiontext_files
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

Expand Down

0 comments on commit 259b08b

Please sign in to comment.