Rails 4: favicon not showing

浪尽此生 提交于 2020-01-13 03:19:25

问题


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' %>

It is located in public/images.

This is the produced HTML:

<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico">

Opening the link in my browser shows the icon correctly.


回答1:


The favicon is not handled by the asset pipeline when its in the public folder, and this can cause caching problems.

See here: How to add favicon in rails 3.2 and Clear the cache from the Rails asset pipeline.

Use the favicon_link_tag and place the .ico file in /app/assets/images/ to get it into the asset pipeline.

If it still doesn't work after that, try clearing your browser cache, your rails cache, and restarting your rails server.



来源:https://stackoverflow.com/questions/31686624/rails-4-favicon-not-showing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!