Search code examples
ruby-on-railsrubyimageherokusrc

Referencing images in a Rails app (Heroku deployment)


I'm currently having a slight problem referencing images in a Rails app which is then deployed to Heroku.

I have an image in the following path relative to the app:

app/assets/images/some-image.png

And I have referenced it in the HTML correctly (as far as I am aware):

<div id="main-nav" class="collapse navbar-collapse">
   <img src="/assets/some-image.png" height="67"/><!-- **IMAGE SOURCE LINK** -->
   <ul class="nav navbar-nav" id="mainNav">
       <li class="active"><a href="#home" class="scroll-link">Home</a></li>
       <li><a href="#introText" class="scroll-link">APR</a></li>
       <li><a href="#initiatives" class="scroll-link">Initiatives</a></li>
   </ul>
</div>

Yet, this is what is displayed:

enter image description here

Does anyone have any ideas why this is happening?


Solution

  • You should use image_tag:

    <%= image_tag "some-image.png", height: "67" %>