refactor and fixes

This commit is contained in:
Alex Turchyn
2023-08-12 12:34:02 +03:00
parent 3b745a650d
commit 47c57158f4
17 changed files with 168 additions and 84 deletions
+1 -14
View File
@@ -7,20 +7,7 @@ module Api
def create
submitter = Submitter.find_by!(slug: params[:submitter_slug])
blob =
if (file = params[:file])
ActiveStorage::Blob.create_and_upload!(io: file.open,
filename: file.original_filename,
content_type: file.content_type)
else
ActiveStorage::Blob.find_signed(params[:blob_signed_id])
end
attachment = ActiveStorage::Attachment.create!(
blob:,
name: params[:name],
record: submitter
)
attachment = Submitters.create_attachment!(submitter, params)
render json: attachment.as_json(only: %i[uuid], methods: %i[url filename content_type])
end