Search code examples
ruby-on-rails-3favicon

Rails Favicon Loading Issue


I have a favicon.ico sitting the root of my public folder and I'm using the following line to load it in the head tag of my application.html.erb

= favicon_link_tag

I only seem to have this issue on localhost and it seems to be throwing off selenium during my testing, but it's really fickle about loading. Sometimes it loads after minutes of waiting, sometimes it doesn't load at all. Sometimes when it loads after minutes of waiting it causes other images that were loaded prior (and successfully) to up and break. Is this just a browser issue? I tested in both Chrome and Firefox. I don't have this problem with any other websites either for any browser. Also worth noting - in my firebug and chrome debuggers I never see the favicon being requested in the network tabs, even when it does load occasionally?

What I've tried:

  • Placing the favicon in both public/images and assets/images
  • Clearing cache in Firefox
  • Chrome incognito mode

Solution

  • Just tested this with a new Rails 3.2.13 and Rails 4.0 application, and it works for me. The favicon loads automatically without having to add the helper to your application layout.

    1) Make sure the file is in your rails_root/public folder

    2) Make sure the file is named favicon.ico