2

I have view diplay.html.erb corresponding to action display in locations controller.
I am using application.js in assets/javascript folder.
I am using javascript function of application.js in the display.html.erb file.
In this function I am loading image but the image is not loaded when used path:
such as "car.png" or "\images\car.png"
but when used path
"http://localhost:3000/assets/car.png" it is displayed properly.


so what path should I give in application.js to access image in /assets/images folder?

1
  • I don't want to give 'localhost:3000' in a path Commented Aug 22, 2012 at 8:40

2 Answers 2

4

There is no confusion,
you need to use http://localhost:3000/assets/car.png to see image
if car.png is located at assets/images/car.png -that's rails convention.

I found the answer:

using <img src="/assets/car.png" /> when car.png in assets/images/car.png

Sign up to request clarification or add additional context in comments.

Comments

-1

You seem to be confused with your own folder structure. If the image is located under /assets/car.png then you should probably use 'assets' instead of 'images' in your path. Doesn't this work?

<img src="/assets/car.png" />

But if the image is under /assets/images/car.png then it would rather be:

<img src="/assets/images/car.png" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.