未设置的图标显示

Favicon displaying without being set

我有一个 rails-backbone 应用程序,其中 /public/images 目录中有一个文件 favicon.ico。我搜索了我的整个代码库,但没有找到引用此图像的单个实例。但是这张图片设置在浏览器选项卡的左上角(就像一个图标)。谁能告诉我这是怎么发生的。

我确定使用此图片有两个原因:
1.如果我删除这个,没有图像显示。
2. 如果我将其替换为其他图像,则会显示新图像。

如有任何帮助,我们将不胜感激! :)

您不必引用它 - 如果您没有在标记中指定它,Web 客户端将自动查找它。

所有 Web 浏览器都会自动识别网站图标,它们不特定于任何 Web 框架。不需要将它们放在根目录(或在本例中为 public/images/ 文件夹),但通常的做法是确保所有浏览器都能找到并识别它们。

特别是在 Rails 中,您应该使用 favicon_link_tag 来提供您的网站图标:

If a page has no link like the one generated by this helper, browsers ask for /favicon.ico automatically, and cache the file if the request succeeds. If the favicon changes it is hard to get it updated.

To have better control applications may let the asset pipeline manage their favicon storing the file under app/assets/images, and using this helper to generate its corresponding link tag.

http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-favicon_link_tag