简体   繁体   中英

How to manage photos uploaded with refile gem hosted on AWS within Activeadmin. Rails

I have a rails application using refile to upload multiple images. I want to be able to manage these images for all the users in Activeadmin so if someone were to upload an offensive photo I can remove it from their profile through activeadmin. I don't know if its important to mention that these photos are being hosted on AWS.

f.inputs "Attachment", :multipart => true do 
          f.input :images, :hint => image_tag(f.object.images.each_with_index do |image, index| 
                attachment_image_tag(image, :file, :fit, 600, 600)

              end)
        end

I have been trying this code and am just getting all the details of the photos back like when it was uploaded, the id, and when it was last updated. This is the only bit of help I was finding online however its not getting me as far as I need. https://github.com/activeadmin/activeadmin/wiki/Showing-an-uploaded-image-in-the-form

Any help with this problem would be great. Thank you!

I ended up figuring it out.

    f.inputs "Images" do
        ul do
            f.label "Click on the images you want to delete, The page will not automatically refresh however the image is being deleted!!"
                f.object.images.each do |img|
                    li do
                        link_to img, remote: true, label: :remove_image, method: :delete do
                            attachment_image_tag(img, :file, :fill, 100, 100)
                        end
                    end

                end
            end

        end

and in the model I put:

def edit @images = Ambassador.images

end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM