Home > database >  Image tag not is showing the images in the first load rails
Image tag not is showing the images in the first load rails

Time:04-29

I'm trying to create a carrousel in rails with bootstrap and I'm using active storage to save the images.

My problem is when I load the page for the first time not is loading the images stored in the s3 bucket, but when I reload the page, the images appear.

I confirm that in the variable img is the image attached.

This is my code:

_carrousel.html.erb

<div id="carouselExampleControls<%=property.id%>"  data-bs-interval="false">
  <div >
      <% count = 0%>
      <% property.property_image.images.each do  |img| %>
        <div >
          <%= image_tag(img, class: "card-img-top d-block background-covr") %>
          <% count  = 1 %>
        </div>
      <% end %>
  </div>
  <button  type="button" data-bs-target="#carouselExampleControls<%=property.id%>" data-bs-slide="prev">
    <span  aria-hidden="true"></span>
    <span >Previous</span>
  </button>
  <button  type="button" data-bs-target="#carouselExampleControls<%=property.id%>" data-bs-slide="next">
    <span  aria-hidden="true"></span>
    <span >Next</span>
  </button>
</div>

Can someone give me a hand or an explanation?

CodePudding user response:

I was able to fix this issue. The problem was turbolinks.

I removed turbolink of application.js and add this library:

gem 'jquery-turbolinks'

that's fixed the issue and continue working with the velocity of turbolink.

  • Related