Let me start by saying I'm open to a better way to do this, but here's what I have so far.
Lets say I have a zip file with 100 images in it. I want to loop through the zip file and 'attach' each image to a record. I have Paperclip installed to attach the image to the record in ActiveRecord. I'm using the following code so far:
Zip::File.open(params['images'].path) do |zipfile|
zipfile.each do |file|
# THIS IS WHAT I'M MISSING
end
end
This is what I'd like to end up with:
Zip::File.open(params['images'].path) do |zipfile|
zipfile.each do |file|
MyModel.create(parent_id: 1, image: "...")
end
end
How could I do that?