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

时间:2018-10-11 11:47:53

标签: ruby-on-rails-5 activeadmin rails-activestorage

我有一个事件模型,其中包含尽可能多的图像字段

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

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

1 个答案:

答案 0 :(得分: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