/favicon.ico Supplied with Rails 4 routes

This is strange. Today I launched a new Rails 4 application and then created a resource called transfer_functions. When I click on a URL like localhost: 3000 / transfer_functions / 1, it adds /favicon.ico to the end and I get this error in the server console.

ActionController::RoutingError (No route matches [GET] "/transfer_functions/1/favicon.ico"):

Any ideas? Thank!

The app uses the "turbolinks" gem.

Update:

I use Twitter Bootstrap and create a mock application with the appropriate generator. I removed this line from the application.html.haml file and fixed this problem.

%link(href="favicon.ico" rel="shortcut icon")

Not sure if I understand why this caused the problem.

+5
source share
3 answers

, , , , , : " favicon.ico ". haml, , html, <link href="favicon.ico...".

:

  • favicon : your_webapp/app/assets/images/

  • your_webapp/app/views/layouts/application.html.haml : = favicon_link_tag

Rails , . URL-.

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

, , rel

+10

favicon.ico Rails 4, favicon_link_tag .

application.html.slim:

DOCTYPE html
html
  head
    = favicon_link_tag

favicon.ico app/assets/images.


:

, favicon. . , "rel" "type".

: rel - , - " "

: type - mime, - '/vnd.microsoft.icon

0

We regularly see 404 in our logs for requests for "old versions" of the badge. On each new release (and therefore on each new precompile), a new favicon file is created with a unique hash. This, apparently, breaks down when someone has saved the icon, for example. by placing a shortcut on your site on your iOS home screen: the icon is lost and the broken icon icon is displayed. Therefore, we abandon the approach to favicon_link_tag/ assets and return back to the icon stored in the folder public, just include:

<link href="favicon.ico">
<link href="favicon_ios.png" rel="apple-touch-icon" type="image/png">

Or in our case in HAML:

%link{:href => 'favicon.ico'}
%link{:href => 'favicon_ios.png', :rel => 'apple-touch-icon', :type => 'image/png'}
0
source

All Articles