Show clip image in Active Admin column

I can display the image file name in a column in Active Admin, but I cannot show the actual image to show

I have a connection where

Member
has_many :member_images

MemberImage
belongs_to :member

I can upload the image in order, all associations in place.

So, to show the file name, I do

column "Filename" do |f|
  f.member_images.map(&:photo_file_name).join("<br />").html_safe
end

And I tried this to show the actual image

column "Images" do |m|
  m.member_images do |img|
    image_tag(img.photo.url(:thumb))
  end
end

But I get this view error

<ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_CollectionProxy_MemberImage:0x007f9634a3f760>

Can anyone tell me what I'm doing wrong?

thank

EDIT

Added .each, so I repeat every image, but now I get this display

[#<MemberImage id: 1, member_id: 1, created_at: "2014-02-18 20:28:33", updated_at: "2014-02-18 20:28:33", photo_file_name: "associations.jpg", photo_content_type: "image/jpeg", photo_file_size: 140780, photo_updated_at: "2014-02-18 20:28:33">]
+3
source share
3 answers

Try iterating the images:

column "Images" do |m|
  m.member_images.each do |img|
    image_tag(img.photo.url(:thumb))
  end
end
+4
source

span image_tag

column "Images" do |m|
  m.member_images.each do |img|
    span do
      image_tag(img.photo.url(:thumb))
    end
  end
end
+2

, :

column "Images" do |m|
  ul do 
    m.member_images.each do |img|
      li do
        image_tag(img.photo.url(:thumb))
      end
    end
  end
end

Although I'm not quite sure why this works.

0
source

All Articles