Isabella
Isabella

Reputation: 37

Image not being displayed

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

Answers (4)

Jyothu
Jyothu

Reputation: 3154

Just use

<%= image_tag 'image_name_with_extension' %>

Upvotes: 0

channa ly
channa ly

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

Hishalv
Hishalv

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

Dominic Goulet
Dominic Goulet

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

Related Questions