I have this PostApplication Model and PostApplication has_many Documents in this below activeadmin resource which contains has_many form.
I want to show various records of Document model based on the boolean is_scanned and I want to create documents in the different tabs through postapplication model only but in the second tab whenever i upload a new file it updates the last existing document
Please Help
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