dgreen22
dgreen22

Reputation: 398

How to show persisted images in ActiveAdmin?

ActiveAdmin automatically pulls up the persisted information for an object when the update form is displayed. It doesn't show the images though - doesn't even show the name in my form - how do I fix this to show the actual image and it's name?

ActiveAdmin.register Art do

permit_params :art_pic_attachments_attributes: [:id, :picture, :_destroy]

 form(html: { multipart: true }) do |f|
    f.inputs do

        f.has_many :art_pic_attachments, allow_destroy: true, heading: 'Images' do |ff|
            ff.file_field :picture, required: true, heading: "Pictures"
        end

    end
        f.actions
 end 

Upvotes: 1

Views: 1414

Answers (1)

Piers C
Piers C

Reputation: 2978

Maybe this wiki article will help. The key is to use an image tag as the input hint.

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

Upvotes: 2

Related Questions