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?

4

2 回答 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

于 2012-08-23T05:03:33.517 回答
-1

您似乎对自己的文件夹结构感到困惑。如果图像位于 /assets/car.png 下,那么您可能应该在路径中使用“assets”而不是“images”。这不行吗?

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

但是如果图像在 /assets/images/car.png 下,那么它宁愿是:

<img src="/assets/images/car.png" />
于 2012-08-22T10:59:27.663 回答