Rails 4: favicon not showing - ruby-on-rails

My favicon just won't show, in Chrome or Firefox. This is how I am rendering it in the <head> section:
<%= favicon_link_tag 'favicon.ico' %>
It is located in public/images.
This is the produced HTML:
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico">
Opening the link in my browser shows the icon correctly.

The favicon is not handled by the asset pipeline when its in the public folder, and this can cause caching problems.
See here: How to add favicon in rails 3.2 and Clear the cache from the Rails asset pipeline.
Use the favicon_link_tag and place the .ico file in /app/assets/images/ to get it into the asset pipeline.
If it still doesn't work after that, try clearing your browser cache, your rails cache, and restarting your rails server.

Related

Rails assets not cached in firefox

My rails app is in production mode and assets are compiled and i can see it in /public/assets/
In my layouts i use something like that :
<%= stylesheet_link_tag "application", media: "all" %>
<%=> javascript_include_tag "application" %>
my javascript use the //require directive,
my css is in "css.scss" ans i use the #import sass directive to load css.scss files.
The assets are well compiled.
When i use chrome, my css and js file are cached :
application-***********.js and css are loaded one time then it is well cached in chrome. I can navigate quickly between my pages ...
When i use firefox, each time it download the js and css concatenated files ... browing is slow ....
Have any idea about this behavior?
Thanks!
Solved : I don't know why but from the moment i start firebug, my application.js and css are each time reloaded (cache miss).
But if i restart firefox and i browse my website without launching at least one time firebug, everything goes well and i can naviguate "quickly" because the browser cache works !!!
Strange, but solved.

Rails pages are linking in non-existent css file when using Stylus

I am trying to use Stylus with a Rails 4 project, but the asset pipeline seems to be naming the compiled CSS wrong and/or linking to the wrong file. If I generate some assets (rails g assets static_pages) the served pages all end up trying to link to a file that doesn't exist:
<link data-turbolinks-track="true" href="/assets/static_pages.css?body=1" media="all" rel="stylesheet" />
I'm using the stylus gem and I've removed the default one for SASS from my Gemfile. I've also tried stylus_rails, but that seems to be deprecated and it didn't change anything anyways. Has anyone else encountered this issue when using stylus with rails?
I'm really at a loss here; any help would be appreciated. Thanks!

Rails 3, IE assets

Is there a good practice to organizing stylesheet/javascript asset files specifically for IE browsers with asset pipeline enabled in Rails 3? For example, I do not want to litter my .html.erb files with conditional comments similar to below for browser detections.
<!--[if !IE]> -->
According to the conditional comment this is not IE<br />
<!-- <![endif]-->
You could put them into a partial in app/views/layouts/. This is also what Michael Hartl does with HTML5 Shim his tutorial: http://ruby.railstutorial.org/chapters/filling-in-the-layout#sec-partials

Favicon in Ruby on Rails application [duplicate]

This question already has answers here:
Adding icon to rails application
(5 answers)
Closed 9 years ago.
I put favicon.ico into /public/ folder and include the following code into layout page
<%= favicon_link_tag %>
But inspite of it, the icon doesn't display. What should I do?
I have struggled with the same. This is what worked for me:
<%= favicon_link_tag 'favicon.ico' %>
and moving the favicon.ico to the /public/images directory.
Good luck!
I don't know what favicon_link_tag is in your app but in general, there are two ways to create a favicon.
Put your icon file in your app root directory (/public). In this case, you don't have to do anything in your code. (does not work in seamonkey, works in all other browsers I know)
Place a link element in the code of your master view:
<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/relative/path/to/file.ico" />

File asset fingerprint is not updating correctly on Rails 3.1

In my rails 3.1 app, while deploying, the assets is compiled and gets uploaded successfully.
When I visit the app, the css and js files are referenced but the server give back 404.
<link href="/assets/application-f997bad128b3d8a92ed5619470851dab.css" media="screen" rel="stylesheet" type="text/css" />
<script src="/assets/application-d7eac22b3bc8b4e3620abb21f59a5faa.js" type="text/javascript"></script>
Looking on the server, the fingerprint that is printed on the html markup doesn't match so the server returns 404.
But I wonder how the hell this happens.
So, what are the factors that change the fingerprinting of the manifest files?
Maybe your server wasn't reloaded. I've experienced this issue when Unicorn didn't switch over after sending the USR2 signal to the process. I had to manually kill and restart the process to get it going again.

Resources