Ruby on Rails Saturday, February 9, 2019

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d8fdb320-b0a7-486a-a843-692fa598c0aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment