Search code examples
ruby-on-railsruby-on-rails-5rails-activestorage

Rails 5 each loop activestorage files displays files attributes


I updated Rails to 5.2 version with ActiveStorage

Everything works fine, but when I perform a loop through my model attached files in order to display them as bootstrap cards, I see my files attributes on the page. I don't want it to display anything.

How can I prevent that?

  <strong style="margin: 10px">Files :</strong>
  <div class="card-columns">
  <%= @mymodel.files.each do |file| %>

  <% end %>
  </div>

what it makes on my page


Solution

  • Remove the = from your loop header...

    Instead of

    <%= @mymodel.files.each do |file| %>
    

    Use

    <% @mymodel.files.each do |file| %>
    

    Checkout what the difference is