Search code examples
activeadminrails-activestorageruby-on-rails-5.2

Multiple upload images in active_admin with Active Storage


I found useful article about uploading image using Active Storage in activeadmin: https://medium.com/@maris.cilitis/using-ruby-on-rails-active-storage-image-uploads-for-active-admin-backed-resources-5638a9ca0b46

But how to upload multiple images in activeadmin with Active Storage the same way?


Solution

  • You just need do some changes

    model:

    has_many_attached :images
    

    instead of

    has_one_attached :image
    

    activeadmin:

    permit_params images: []
    
    form do |f|
      f.inputs do
        f.input :images, as: :file, input_html: { multiple: true }
      end
    end
    

    and you'll can choose many files to upload