Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set "shortcut icon" in rails? [duplicate]

<head>
  <title>Application</title>
  <% link { :rel => "shortcut icon", :href => "/images/favicon.ico" } %>
</head>

I can't see the image which i set, What's wrong with the above code? How can i run successfully?

like image 404
romil Avatar asked Oct 18 '12 08:10

romil


2 Answers

See doc:

<%= favicon_link_tag 'favicon.ico' %>
like image 160
apneadiving Avatar answered Sep 30 '22 20:09

apneadiving


favicon_link_tag(source='/favicon.ico', options={})

<%= favicon_link_tag %>

generates

<link href="/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />

You may specify a different file in the first argument:

<%= favicon_link_tag '/myicon.ico' %>

That’s passed to path_to_image as is, so it gives

<link href="/myicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />

The helper accepts an additional options hash where you can override “rel” and “type”.

For example, Mobile Safari looks for a different LINK tag, pointing to an image that will be used if you add the page to the home screen of an iPod Touch, iPhone, or iPad. The following call would generate such a tag:

<%= favicon_link_tag 'mb-icon.png', :rel => 'apple-touch-icon', :type => 'image/png' %>

Method Like

def favicon_link_tag(source='/favicon.ico', options={})
  tag('link', {
    :rel  => 'shortcut icon',
    :type => 'image/vnd.microsoft.icon',
    :href => path_to_image(source)
  }.merge(options.symbolize_keys))
end
like image 24
Dipak Panchal Avatar answered Sep 30 '22 20:09

Dipak Panchal