Last active
October 30, 2022 22:04
-
-
Save michalkorzawski/bf487868d1cd48be02e1aa55e8dc9b3e to your computer and use it in GitHub Desktop.
Revisions
-
michalkorzawski revised this gist
Oct 30, 2022 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,14 +3,14 @@ def some_method ... business logic ... attaching_images = params[:record][:images].presence if attaching_images attaching_images = attaching_images.map do |im| tempfile = ImageConverter.new(tempfile: im.tempfile, width: 1200).call ActionDispatch::Http::UploadedFile.new( { filename: "#{im.original_filename.split('.').first}.jpg", tempfile: tempfile, type: 'image/jpg', head: "Content-Disposition: form-data; name=\"property[images][]\"; filename=\"#{im.original_filename.split('.').first}.jpg\"\r\nContent-Type: image/jpg\r\n" } -
michalkorzawski revised this gist
Oct 24, 2022 . 1 changed file with 23 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,26 @@ # app/controllers/records_controller.rb def some_method ... business logic ... @attaching_images = params[:record][:images].presence if @attaching_images @attaching_images = @attaching_images.map do |im| io = ImageConverter.new(tempfile: im.tempfile, width: 1200).call ActionDispatch::Http::UploadedFile.new( { filename: "#{im.original_filename.split('.').first}.jpg", tempfile: io, type: 'image/jpg', head: "Content-Disposition: form-data; name=\"property[images][]\"; filename=\"#{im.original_filename.split('.').first}.jpg\"\r\nContent-Type: image/jpg\r\n" } ) end end if record.new(permitted_params.merge(images: attaching_images)).save ... else ... end end -
michalkorzawski revised this gist
Oct 23, 2022 . No changes.There are no files selected for viewing
-
michalkorzawski created this gist
Oct 23, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ # records_controller.rb @attaching_images = params[:record][:images].presence if @attaching_images @attaching_images = @attaching_images.map do |im| io = ImageConverter.new(tempfile: im.tempfile, width: 1200).call ActionDispatch::Http::UploadedFile.new( { filename: "#{im.original_filename.split('.').first}.jpg", tempfile: io, type: 'image/jpg', head: "Content-Disposition: form-data; name=\"property[images][]\"; filename=\"#{im.original_filename.split('.').first}.jpg\"\r\nContent-Type: image/jpg\r\n" } ) end end