3

Firefox does not find the favicon of my Rails 3.1 app in production mode. Running in development mode, it works.

I browse to the URL localhost:4000/favicon_standing.ico for both modes. The favicon is located in my public folder of my app. I do not use the asset pipeline for it. I start the server using rails s -p 4000 -e production and rails s -p 4000, respectively, using WEBrick.

Why does is for in development mode, but not in production mode?

Bjoernsen
  • 2,016
  • 1
  • 33
  • 41

2 Answers2

2

I'd try changing the name of your file to 'favicon.ico' and see if that helps. While its not required, its the default naming convention and if you're using another name, you have to add some html to your head:

<link rel="shortcut icon" href="http://www.my-domain.com/myfavicon.ico" type="image/x-icon" />

Here's what some googling shows: http://www.make-a-favicon.com/favicon_FAQs.htm#Are_all_favicon_files_named_favicon.ico

James
  • 69
  • 1
  • 8
  • The reason for having another name is, that I have two Favs. If the App is running a calculation for the user, 'favicon_runnig' should be there. If it is done, 'favicon_standing' will be shown. I use JS for replacing the favicon. In development mode it works. I am using '<%= favicon_link_tag '/favicon_standing.ico'%>' to add the icon. – Bjoernsen Mar 26 '12 at 08:19
  • Sounds like a caching issue then; it development mode everything is reloaded for each request. I believe you can set specific controllers not to cache in production: http://guides.rubyonrails.org/caching_with_rails.html – James Mar 26 '12 at 18:36
  • 1
    Me too facing the same problem.. even after clearing the cache i couldnt see favicon in production but in local it works fine. am using rails 3.1. I have created a favicon and placed inside my public folder but it is not getting displayed in production.. any body could help me in this?? – Abhiram May 08 '13 at 06:02
1

there is a helper for this

<head>
...
<%= favicon_link_tag %>
<!-- you can skip the name of file if it is favicon.ico  -->
...
</head>

all you need is to place your favicon to assets/images/ folder and recompile assets

okliv
  • 3,909
  • 30
  • 47
  • Thank you for your answer. Unfortunately, this question is from 2012 and I got it working (I think) :-) – Bjoernsen Aug 18 '15 at 05:36
  • ) i answered for other google-it-users like me who found your SOP but can be interested in my version of solution – okliv Aug 18 '15 at 11:45