Reputation: 8730
Using active storage to store images which are working fine.
Issue I face is that when I image_tag image
it shows #
instead of image.
Here is the code products.rb
has_many_attached :photos
in active_admin
row "Images" do |p|
p.photos.attachments.each do |photo|
image_tag photo
end
end
it not displaying images. it check with byebug also the url is fine but images not display and it shows this
only this one works
row "Images" do |p|
image_tag p.photos.attachments.last
end
Upvotes: 1
Views: 2282
Reputation: 802
I did not face any issues doing it this way for multiple attachments:
if resource.photos.attached?
row "Photos" do |resource|
resource.photos.map{|photo| image_tag url_for photo}
end
end
I don't know why @uday would suggest ul
and li
. It seems like an "XY solution".
Upvotes: 0
Reputation: 1481
You need to use the url_for
to display the images, something like below
row "Images" do |p|
ul do
p.photos.each do |photo|
li do
image_tag url_for(photo)
end
end
end
end
Upvotes: 6