Here is the solution I developed:
In the app /admin/posts.rb
f.has_many :attachments, for: [:attachments, f.object.attachments_including_hidden] do |a| ... end
And in app / models / posts.rb
def attachments_including_hidden Attachment.unscoped.where( attachable_id: id ) end
(where Attachment model belongs__ :: attachable, polymorphic: true)
What's happening? ActiveAdmin uses Formtastic, which uses the Rails Form Builder. The form.has_many method is an ActiveAdmin method that calls Formtastic form.inputs, which in turn calls the Rails_for fields. Option: for the option, fields_for will be passed completely down, which can take a collection (as its second argument), so I deliver this collection to it explicitly.
source share