From 952168aaebf46d161ee28fccf56cccbb5ace184f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 2 Mar 2023 19:23:16 -0800 Subject: [PATCH] save settings from basil properly --- app/controllers/basil_controller.rb | 4 +++- config/initializers/paperclip.rb | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/basil_controller.rb b/app/controllers/basil_controller.rb index 269a7ac7..7af09ee4 100644 --- a/app/controllers/basil_controller.rb +++ b/app/controllers/basil_controller.rb @@ -185,9 +185,11 @@ class BasilController < ApplicationController def complete_commission commission = BasilCommission.find_by(job_id: params[:jobid]) + return if commission.nil? + commission.update( completed_at: DateTime.current, - final_settings: params[:settings] + final_settings: JSON.parse(params.fetch(:settings, {})) ) # TODO: we should attach the S3 object to the commission.image attachment diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 8f640f20..10b89f3b 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -1,3 +1,8 @@ -# TODO we can probably remove this. Need to figure out what we're using for uploads again. - -# Paperclip::Attachment.default_options[:url] = ':s3_domain_url' +# We don't want to use Paperclip forever, but we're adding the following interpolater +# to enable attaching images that are already in S3 (created by Basil) and we haven't +# migrated to ActiveStorage yet so... here we are. +# JK LOL THIS DOESN'T EVEN WORK SO FEEL FREE TO DELETE AT WILL +# Paperclip.interpolates :src_or_default do |attachment, style| +# attachment.instance.src_path || +# attachment.interpolator.interpolate(":class/:attachment/:id_partition/:style/:filename", attachment, style) +# end \ No newline at end of file