Reputation: 37
need help in displaying image.I have an image called 'train' in 'app/assets/images/'
In the view I am using
<%= image_tag "app/assets/images/train.png" %>
I only get the name of the image(Train) but not the image.
I also tried
<%= image_tag("train.png")%>.
Thank you
Upvotes: 1
Views: 2184
Reputation: 9937
If you have trains.png located in public/assets/images you should use:
<%=image_tag("images/train.png")%>.
If you use
<%= image_tag("train.png")%>
your train.png image is supposed to be in the assets/ folder.
Upvotes: 2
Reputation: 3052
Ok so you are using asset pipeline, in your terminal under root directory try typing this
rake assets:precompile
and stick to using
<%= image_tag("train.png") %>
, as using the other form might cause problems for you later in production environment.
If the problem persists i recommend checking out a tutorial here on the asset pipeline or creating a new app here
Upvotes: 0
Reputation: 8113
You have to use the following statement :
image_tag("train.png")
Where train.png
is the path after /app/assets/images/
.
Also, make sure that the assets are compiled :
rake assets:precompile
Upvotes: 0