Issue
Very basic question, but somehow I can't get it to work. I am trying to have an image located in project's local folder to display on Rails. Additionally, I am using bootstrap; thus I need to declare class: "img-responsive"
as well. Here is the original code: <img class="img-responsive" src="assets/img/mockup/img2.jpg" alt="">
I have consulted this post which suggested <%= image_tag("xyz.png", class: "img-responsive img-thumbnail img-circle") %>
and rubyonrails guide which suggested image_tag("/icons/icon.gif", class: "menu_icon")
.
I have tried
<%= image_tag ("assets/img/mockup/img2.jpg", class: "img-responsive")%>
and
<%= image_tag "assets/img/mockup/img2.jpg" %>
But it still does not work.
I can confirm that the path is: app/assets/img/mockup/img2.jpg
How can I display the said image on rails app view?
Solution
I was browsing and saw this SO post. I was able to get it work using
<%= image_tag ("/assets/mockup/img2.jpg"), class: "img-responsive"%>
Image path was assets/images/mockup/img2.jpg
; omitting images
from the image path assets/mockup/img2.jpg
solves the issue.
Answered By - Iggy Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.