Rails 4:网站图标未显示 [英] Rails 4: favicon not showing
问题描述
我的收藏夹图标不会在Chrome或Firefox中显示.这就是我在<head>
部分呈现的方式:
My favicon just won't show, in Chrome or Firefox. This is how I am rendering it in the <head>
section:
<%= favicon_link_tag 'favicon.ico' %>
它位于public/images
中.
这是产生的HTML:
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico">
在浏览器中打开链接会正确显示图标.
Opening the link in my browser shows the icon correctly.
推荐答案
当收藏夹图标位于公用文件夹中时,它不会由资产管道处理,这可能会导致缓存问题.
The favicon is not handled by the asset pipeline when its in the public folder, and this can cause caching problems.
请参阅此处:如何在rails 3.2中添加favicon 和从Rails资产管道中清除缓存.
使用 favicon_link_tag 并将.ico文件放在/app/assets/images/
中,以进入资产管道.
Use the favicon_link_tag and place the .ico file in /app/assets/images/
to get it into the asset pipeline.
如果在此之后仍然无法正常工作,请尝试清除浏览器缓存,rails缓存,然后重新启动rails服务器.
If it still doesn't work after that, try clearing your browser cache, your rails cache, and restarting your rails server.
这篇关于Rails 4:网站图标未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!