show the loaded image actiontext

16 views
Skip to first unread message

nikola...@gmail.com

unread,
Feb 9, 2019, 4:33:20 AM2/9/19
to Ruby on Rails: Talk
Hello! Help me, please, I use actiontext, and I try to display the loaded image, here are my attempts to show in the partial

attention to this: <% ActiveStorage::Attachment.where(record: post.body.id).limit(1).each do |img| %>

_post.html.erb

<% cache post do %>
 
<%= link_to post, class: 'card' do %>

   
<% ActiveStorage::Attachment.where(record: post.body.id).limit(1).each do |img| %>
     
<% if img.blob.representable? %>
       
<%= image_tag img.blob.representation(resize_to_fill: [ 50, 50 ]) %>
     
<% end %>
   
<% end %>

 
<% end %>
<% end %>

How to do it right?

Thanks!

**Rails version**: 6.0.0.beta1
**Ruby version**: 2.6.0
Reply all
Reply to author
Forward
0 new messages