Home>

ruby 2.6.3
rails 5.2.4.4
Introduced devise, active storage
Packet confirmed with s3

I want to get the initial image saved in assets on heroku The problem i am having

Initial images saved in assets that can be loaded locally are not loaded by heroku.

Corresponding source code
<% @ gear1.each do | gear |%>
      
        
        <% if gear.image.attached?%>
          <% = image_tag gear.image, class: "index-img"%>
        <% else%>
            
        <% end%>
      ..
      ..
      ..

* Both the initial image and the uploaded image can be read locally.

  • Answer # 1

    I think you should use image-url.

    If you use an asset pipeline, you will eventually need to convert the path to the asset. To this end, the sass-rails gem provides a variety of helpers whose names end in -url or -path (hyphens in Sass, but underscores in Ruby). The asset classes that the helper supports are images, fonts, video, audio, JavaScript, and stylesheets.

    image-url ("rails.png") is converted to url (/assets/rails.png)
    image-path ("rails.png") is converted to "/assets/rails.png"

    Reference: Rails Guide