0

I have a working dashboard using dashing (http://dashing.io/) and I'd like to place a static image that I have stored in my assets/images folder as part of a banner across the top of the dashboard.

I'm trying to get this to work at the top of my dashboard.erb file: <img src="/assets/images/test_image.png">

This won't display an image at the top of dashboard, but when it's located elsewhere then <img src="exampleurl.com/images/test_image"> will display the image.

I think I'm missing something major here and I imagine it's to do with Sprockets from the reading I've done, but I don't quite understand the implementation.

skeltont
  • 86
  • 8

2 Answers2

2

My goal was to have a static image placed at the top of my dashing dashboard that I referenced from the assets folder in the webroot. After trying to figure out how to reference the image locally in the dashboard.erb file, I found that if your image placed in /assets/images/test_image.png then the resulting html looks like:

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

At this point the image should show up on your dashboard.

I hope this helps someone else!

skeltont
  • 86
  • 8
0

If you are using Sprockets. What about use the ERB helper <%= image_tag "test_image.png" %> ??

The ERB helper will link to the correct path where Sprockets compile the assets.

The Sprockets behaviour when compiling your assets is put it on a path as it was on public. Actually it's ./public/assets/.... So, even if you don't want to use the ERB helper, you could access your assets pointing to <img src="/assets/test_image.png">

But, if you put your image files directly inside public/images you must point your src to <img src="images/test_image.png">

cefigueiredo
  • 738
  • 3
  • 12
  • There is no public folder in the webroot for this dashing, but I was able to get it working finally. Even though the image is located in /assets/images/test_image.png it was able to be referenced through assets/test_img.png. Thank you for your help! – skeltont Sep 08 '14 at 17:20