Skip to content
Prev Previous commit
Next Next commit
initial stab at getting remixes to accept new or updated images
  • Loading branch information
loiswells97 committed Jun 11, 2025
commit c17a16d3616e30a2ad6093ad5b3d6e073e43385d
2 changes: 1 addition & 1 deletion app/controllers/api/projects/remixes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def remix_params
:videos,
:audio,
:instructions,
image_list: %i[filename url content],
image_list: [:filename, :url, {content: [] }],
components: %i[id name extension content index])
end
end
Expand Down
10 changes: 10 additions & 0 deletions lib/concepts/project/operations/create_remix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ def create_remix(original_project, params, user_id, remix_origin)
original_project.images.each do |image|
remix.images.attach(image.blob)
end
params[:image_list].each do |image|
if image[:content].present?
remix.images.attach(io: StringIO.new(image[:content].pack('C*')), filename: image[:filename])
end
end

original_project.images.each do |image|
existing_image = remix.images.find { |img| img.filename.to_s == image.filename.to_s }
remix.images.attach(image.blob) unless existing_image
end

original_project.videos.each do |video|
remix.videos.attach(video.blob)
Expand Down