Episodes
Helmut said over 1 year ago on Bulk Upload with Active Storage :
Thanks very much for this, it's very helpful to not have to worry about Rails forgetting what files have been uploaded in a form previously, and also having an easy way to delete uploads. 

 I'm a beginner and just wondering about the best way to  incorporate this approach into an existing form and model  (I'm creating Invoices and want the user to be able to attach scans of receipts in the Invoice form they're filling out, and be able to add new scans without having to upload existing ones again, and be able to delete any scans easily). I'm thinking of doing this using your approach to accepting nested attributes in my Invoice form with Stimulus JS (I got this from Episode 186, thanks!).  Does this sound like a reasonable approach? I already use it for adding Line Items in the Invoice, and it seems like the same concept would work with this approach to Active Storage uploads, since each uploaded is its own post. 

I guess I'm going to try it, unless  anyone has a better idea. Otherwise, I'm not sure how I would associate these Active Storage instances with a parent  (like Invoice, or Post, etc.) and doing it all in one convenient form.  

Thanks for the great episode!

 

Simon Moro PRO said over 1 year ago on Bulk Upload with Active Storage :
Thanks for this, Dave!

This is SO much cleaner than the hack I tried to do that looked like this... Plus I also had other logic around project count track limits... I appreciate the tutorial :)

if files.length > 0
    files.each do |f|
      @project.tracks.create(mp3_file: ActiveStorage::Blob.find_signed(f), file_size_limit: file_size_limit)
    end
end

jacoby PRO said over 1 year ago on Bulk Upload with Active Storage :
Hi David!

Is there a way to configure Active Storage to use "uuid" as the type for :id, :blob_id, :record_id, etc. Using the MediaUploaderController, I want every medium to belong to the user that uploaded it. BUT my media isn't persisted because the ids are of type "bigint".

Login to Comment