Awesome Open Source
Awesome Open Source

Rails Env Favicon

Gem Version

Made changes in the code to debug and do not understand what's wrong. Hell, I'm on the debug production! This happened to you? To me several times. Library offers one of the ways to solve this problem.

Most everyone will understand from one picture:


This means that on the first tab we have development environment, on second stage, and third it's production(we don't need change this favicon).

It uses Tinycon - A small library for manipulating the favicon.

And one more option:


Icon will be gray on non production environment.

It you need this separately you can use Grayscale-Favicon - adopted for node package managers version.

Js usage for this task justified by the fact that more often than not have to worry about favicon caching, because favicon changes on the fly after it's loaded. However, if you do not like to use js for this problem, you may use alternative version of gem which uses, follow to branch rmagick


Add this line to your application's Gemfile:

gem 'rails-env-favicon'

And then execute:

$ bundle


# adds initializer
rails g rails_env_favicon:install

In your JavaScript manifest (e.g. application.js):

//= require rails_env_favicon


In config/initializers/rails_env_favicon.rb

RailsEnvFavicon.setup do |config|
  # If true then favicon will be gray on non production env
  config.make_grayscale = false
  # or if make_grayscale = false then draw badge on favicon with this options:
  config.text_color = '#ffffff'
  config.background_color = '#549a2f'

You can also configure the condition of changing favicon and badge label, just override RailsEnvFavicon module methods. For example:

module RailsEnvFavicon
  def self.badge_label
    ENV['TEATRO'].present? ? 'T' : ::Rails.env.first.upcase

  def self.applicable?
    !::Rails.env.production? || ENV['TEATRO'].present?


  • If you change a configuration to apply changes, you have to:

    • Execute rm -rf tmp/cache/* in app directory, for assets cache cleaning.
    • Restart web server.


  1. Fork it ( )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
javascript (70,419
ruby (12,898
rails (667
environment (68
favicon (27