【发布时间】:2020-07-23 21:46:42
【问题描述】:
我创建了一个包含多个画廊的作品。
class Production < ApplicationRecord
has_many :galleries
accepts_nested_attributes_for :galleries, :allow_destroy => true
...
一个画廊有_one_attached照片
class Gallery < ApplicationRecord
has_one_attached :photo
end
在我的 ActiveAdmin 表单中,我添加了一个 has_many 字段和一个要显示的条件图像。
...
f.has_many :galleries, allow_destroy: true do |g|
g.input :photo, as: :file
g.input :caption
if g.object.photo.attached?
image_tag(g.object.photo.variant(resize: '200x200^'))
end
end
...
图像显示,问题是图像显示与相关字段分开。图库中所有上传的图像都显示在整个字段上方 - 就在字段标签上方。有什么方法可以将相关字段和示例图像一起保存在标记中?任何帮助将不胜感激,谢谢!
【问题讨论】:
标签: ruby-on-rails activeadmin rails-api