How to Add a Favicon in Ruby on Rails Apps

Favicons are this nifty little icons on the tab of your browser to help give a little personalized identity rather than the blank page one which is the default

This is one of the super fast things to fix yet I forget every time I build out a Rails app. Favicons can be created with a plethora of different sites. I’m old school and keep using DynamicDrive ( as it has limited advertising and junk on the site.

The code block is super easy to remember…except when I need to remember it, so here it is:

<%= favicon_link_tag asset_path('image-name.ico') %>

Here are the steps to set up your favicon in your Rails app:

  1. Generate your icon
  2. Copy the icon to the app/assets/images folder
  3. Create the pointer in the HEADsection of your app/views/layouts/application.html.erb file as shown here:

Reload the server your server and you’re off to the races!  Once you restart your app you should see your new icon appear. There may be some delay because some browsers (Chrome being the main culprit) believe in caching everything to save you time on loading. This creates problems because sometimes the cache invalidation takes a while when you legitimately want to see an update.

This will be the end result:

Hopefully this is helpful and saves you a little hunting for the solution.

Ruby on Rails tip – generating a project with specific rails version

Let me qualify that I am sporting the “noob” title with my Ruby on Rails development. That being said, I hope that I can offerRuby on Rails some small help to other new RoR folks as I learn the ropes myself.

This is a simple tip which I have found very handy since I’ve updated my rails to 3.0.0 this week. If you need to generate a new project but need to use a “legacy” version of rails then you simply include the version within your code using this syntax:

rails _version_ projectname

So my current need to use 2.3.5 for a site uses this command line:

rails _2.3.5_ mysite

Small tip but big help for those like me who have to manage and support multiple versions of Rails across environments.