开发者

Rails ActionController::UnknownAction for favicon

开发者 https://www.devze.com 2023-03-08 07:16 出处:网络
I have following line in myapp/views/layouts/application.html.erb <link rel=\"shortcut icon\" href=\"images/favicon.ico\" type=\"image/x-icon\" />

I have following line in my app/views/layouts/application.html.erb

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

This somehow causes following error message int he logs and the favicon is not loaded. This happens only for certain paths not for the whole 开发者_开发问答application.

ActionController::UnknownAction (No action responded to images. Actions: 

How to get rid of it ?


Use the favicon_link_tag helper instead:

<%= favicon_link_tag "/favicon.ico" %>

Just make sure your favicon.ico file is in the public folder... and do not forget the forward slash.


Believe me.. try prefixing images with a slash and this should work

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

精彩评论

暂无评论...
验证码 换一张
取 消