Showing an uploaded image in the form - activeadmin/activeadmin GitHub Wiki
To show a preview of a form image, use the :hint form parameter, like so (thank to Greg Tangey for this on the mailing list:
f.inputs "Attachment", :multipart => true do
f.input :cover_page, :as => :file, :hint => image_tag(f.object.cover_page.url)
f.input :cover_page_cache, :as => :hidden
end
Of course you can still do all the processing you are used to from PaperClip or CarrierWave:
f.inputs "Attachment", :multipart => true do
f.input :cover_page, :as => :file, :hint => image_tag(f.object.cover_page.url(:thumb))
f.input :cover_page_cache, :as => :hidden
end
Also you can prevent error if image not uploaded yet:
f.inputs "Attachment", :multipart => true do
f.input :cover_page, :as => :file, :hint => f.object.cover_page.present? \
? image_tag(f.object.cover_page.url(:thumb))
: content_tag(:span, "no cover page yet")
f.input :cover_page_cache, :as => :hidden
end
Remember the :image_cache
input to get previews in non-saved records with e.g. CarrierWave. See Ryan's Railscast on CarrierWave for more information.