I am using ActiveStorage to store images for the post. My model looks like this
class Post
has_many_attached :images
end
I am able to save image in active storage. But I am not able to preview them. I am able to display download link and then view the image. My code looks like this
<% @post.images.each do |image| %>
<%= link_to "View", image %>
<% end %>
But I want to display image rather than download link. So how can i preview the images ? I tried something like this and it didn't work
<% @post.images.each do |image| %>
<%= image_tag(image) %>
<% end %>
I also tried installing poppler
gem and tried like this, but this also didn't work.
<%= image_tag image.preview(resize_to_limit: [100, 100]) %>
Update:
<%= image_tag(image) %>
worked. I was not able to view the image because size of image was too big so I had to scroll down.
<%= image_tag(image) %>
worked. I was not able to view the image because size of image was too big so I had to scroll down.