如何使用活动存储将图像上载字段添加到active_admin

问题描述 投票:0回答:1

我有一个事件模型,其中包含许多图像字段

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

如何在上述字段的活动管理事件仪表板上创建和允许图像?我使用active_storage作为我的图像上传器

ruby-on-rails-5 activeadmin rails-activestorage
1个回答
0
投票

尝试这样的事情:

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
© www.soinside.com 2019 - 2024. All rights reserved.