Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I do multiple uploads in Active Storage?

Arthur Truong asked in Rails

Hi there,

I am following this tutorial to do multiple file uploads with DropboxJS but I don't know how to get multiple images belonging to a model to show in the 'show' page. Only one image shows when I upload multiple images, despite doing a .each in the@post.feature_image array.
Tutorial here:
https://web.archive.org/web/20191223022642/https://web-crunch.com/rails-drag-drop-active-storage-stimulus-dropzone/

Example Repo: https://github.com/justalever/drag_and_drop_active_storage

Changes I have made to get it working:
_form.html.erb

data-dropzone-max-files="10"

posts/show.html.erb

 <%= link_to @post do %>
    <% @post.feature_image.each do |image| %>
      <%= image_tag image %>
    <% end %>
  <% end %>

models/post.rb

class Post < ApplicationRecord
  belongs_to :user
  has_many_attached :feature_image
end
Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.