Rails 4 和 Leaflet:找不到资产/图像? [英] Rails 4 and Leaflet: assets/images not found?

查看:31
本文介绍了Rails 4 和 Leaflet:找不到资产/图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个真正不应该成为问题的问题.由于某种原因,我在 app/assets/images 中的图像无法访问.当我请求他们时,我只会得到 404.

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

这真的应该是一个脑残的简单修复......最多重新启动服务器.我已经重新启动了服务器,我已经检查了文件权限以确保文件对它们具有合理的权限......当我加载我的页面时仍然得到 404.

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.

我在这里错过了什么?

使用 Rails 4.

Using Rails 4.

推荐答案

用这个助手获取你的图像:

Just get your image with this helper :

image_path('marker-shadow.png')

rails生成的路径是/assets/marker-shadow.png",没有'images'文件夹.

The path generated by rails is "/assets/marker-shadow.png" without the 'images' folder.

这篇关于Rails 4 和 Leaflet:找不到资产/图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆