Ruby on Rails 应用程序中的 Favicon
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11071445/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Favicon in Ruby on Rails application
提问by Alexandre
I put favicon.icointo /public/folder and include the following code into layout page
我把favicon.ico到/public/文件夹,包括下面的代码到页面布局
<%= favicon_link_tag %>
But inspite of it, the icon doesn't display. What should I do?
但尽管如此,该图标并未显示。我该怎么办?
回答by Anil
I have struggled with the same. This is what worked for me:
我也有同样的挣扎。这对我有用:
<%= favicon_link_tag 'favicon.ico' %>
and moving the favicon.icoto the /public/images directory.
并将其移动favicon.ico到 /public/images 目录。
Good luck!
祝你好运!
回答by toniedzwiedz
I don't know what favicon_link_tagis in your app but in general, there are two ways to create a favicon.
我不知道favicon_link_tag您的应用程序中有什么,但总的来说,有两种方法可以创建网站图标。
- Put your icon file in your app root directory(
/public). In this case, you don't have to do anything in your code. (does not work in seamonkey, works in all other browsers I know) Place a
linkelement in the code of your master view:<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/relative/path/to/file.ico" />
- 将您的图标文件放在您的应用程序根目录(
/public) 中。在这种情况下,您无需在代码中执行任何操作。(不适用于 seamonkey,适用于我知道的所有其他浏览器) link在主视图的代码中放置一个元素:<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/relative/path/to/file.ico" />

