foliwe83
foliwe83

Reputation: 590

How to add image upload fields to active_admin with active storage

I have an Event Model which as many images fields

class Event < ApplicationRecord
  has_one_attached :poster
  has_one_attached :ticket_image
  has_many_attached :images
end

How can I create and permit images on active admin events dashboard with the above fields? I am using active_storage as my image uploader

Upvotes: 3

Views: 2203

Answers (1)

wolflee
wolflee

Reputation: 21

Try something like this:

ActiveAdmin.register Event do
  ...
  form do |f|
    input :poster, as: :file
    input :ticket_image, as: :file
    input :images, as: :file, input_html: { multiple: true }
  end

  permit_params :poster, :ticket_image, images: []
end

Upvotes: 2

Related Questions