I can display an images filename in a column within Active Admin but i cannot seem to get the actual image to show
I have a relationship where
Member
has_many :member_images
MemberImage
belongs_to :member
I can upload an image fine, all associations are in place.
So to show the filename i do
column "Filename" do |f|
f.member_images.map(&:photo_file_name).join("<br />").html_safe
end
And i have 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 error in the view
<ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_CollectionProxy_MemberImage:0x007f9634a3f760>
Can anyone advise what i am doing wrong please
Thank You
EDIT
Have added a .each so i iterate through each image but now i get this displayed
[#<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">]
Try iterate on you images:
column "Images" do |m|
m.member_images.each do |img|
image_tag(img.photo.url(:thumb))
end
end
Fixed it by add span or other blocks to your image_tag
column "Images" do |m|
m.member_images.each do |img|
span do
image_tag(img.photo.url(:thumb))
end
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With