Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 and Leaflet: assets/images not found?

I am having a problem that really should not be a problem. For some reason the images I have in app/assets/images are not accessable. When I request them I just get a 404.

./log/development.log:Started GET "/assets/images/marker-shadow.png" for 127.0.0.1 at 2013-07-20 22:02:38 -0400
./log/development.log:ActionController::RoutingError (No route matches [GET] "/assets/images/marker-shadow.png"):

mike@sleepycat:~/projects/myapp$ ls app/assets/images/
marker-icon-2x.png  marker-icon.png  marker-shadow.png

This really should be a braindead easy fix... restarting the server at most. I have restarted the server, I have checked the file permissions to make sure the files have sane permissions on them... and I still get 404's when I load my page.

What am I missing here?

Using Rails 4.

like image 879
mikewilliamson Avatar asked Jul 21 '13 15:07

mikewilliamson


1 Answers

all you have in app/assets/images/ folder you can access with direct path

'/assets/marker-icon-2x.png'
...

there is asset helper for this to use it inside erb:

asset_path('marker-icon-2x.png')

for images inside scss it becomes:

image-path('marker-icon-2x.png')

because folders app/assets/[images||stylesheets||javascripts] are map like one folder /assets with asset pipeline framework

note that helper image_tag('marker-icon-2x.png') "knows" already where the image is

like image 149
okliv Avatar answered Oct 30 '22 22:10

okliv