Curated list of episodes, bundled to help you on your learning path!
Videos of tech, infrastructure, hardware and software which non-instructional by nature.
Articles around software and tutorials.
Show your love and support while looking fancy.
Got a question or want to chat about a topic? Let's talk!
if files.length > 0
files.each do |f|
@project.tracks.create(mp3_file: ActiveStorage::Blob.find_signed(f), file_size_limit: file_size_limit)
class Image < ApplicationRecord
class Album < ApplicationRecord
has_many :images, dependent: :destroy
accepts_nested_attributes_for :images, allow_destroy: true, reject_if: :all_blank
<%= form_with url: album_images_uploads_path(@album), multiplart: true do |form| %>
<%= form.file_field :file, multiple: true, direct_upload: true %>
<%= form.submit %>
<% end %>
class ImagesUploadsController < ApplicationController
params[:file].each do |blob|
@album = Album.find(params[:album_id])
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!
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 :)
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".
The only difference is that I have an Album and this album has_many Image model and this image model has_one attached :file
this is what gets send from the form