我在下面的activeadmin资源中有这个PostApplication Model和PostApplication has_many Documents,其中包含has_many表单。
我想基于布尔 is_scanned 显示Document模型的各种记录,我想通过postapplication模型在不同的选项卡中创建文档,但是每当我上传新文件时它都会在第二个选项卡中创建它更新最后一个现有文件
请帮助
ActiveAdmin.register PostApplication do
form do |f|
tab "Documents" do
tabs do
tab "Not Scanned" do
f.has_many :documents, for: [:documents, f.object.documents.where(is_scanned: false) || Document.new(is_scanned: false)] do |la|
la.semantic_errors *la.object.errors.keys
la.input :verified
la.input :document, as: :file, required: false, :hint => (la.object.new_record? || !la.object.document.exists? ? "" : link_to("Download", "#"))
la.input :_destroy, as: :boolean, required: false, label: t('remove')
end
end
tab "Scanned" do
f.has_many :documents, for: [:documents, f.object.documents.where(is_scanned: true) || Document.new(is_scanned: true)] do |la|
la.semantic_errors *la.object.errors.keys
la.input :verified
la.input :document, as: :file, required: false, :hint => (la.object.new_record? || !la.object.document.exists? ? "" : link_to("Download","#"))
la.input :_destroy, as: :boolean, required: false, label: t('remove')
end
end
end
end
end
end