class Erector::Widgets::EnvironmentBadge

Displays a colored badge in the upper-left corner signifying the environment the app is running in. Inspired by Assaf Arkin

<http://blog.labnotes.org/2009/10/08/using-a-badge-to-distinguish-development-and-production-environments/>

Erectorized by Alex Chaffee

Public Instance Methods

content() click to toggle source
# File lib/erector/widgets/environment_badge.rb, line 10
      def content
        style "#environment_badge { position: fixed; left: 1em; font-weight: bold; padding: .2em 0.9em; text-transform: uppercase; display: none }
#environment_badge.staging { color: #000; background: #ffff00; border: 2px solid #cccc20; }
#environment_badge.development { color: #fff; background: #ff0000; border: 2px solid #cc2020; }
#environment_badge.staging, #environment_badge.development { border-top: none; display: block; opacity: 0.6 }    
"
        unless environment =~ %rproduction/
          p environment, :class => environment, :id => "environment_badge"
        end
      end
environment() click to toggle source
# File lib/erector/widgets/environment_badge.rb, line 22
def environment
  RAILS_ENV
rescue NameError
  ENV['RAILS_ENV'] || ENV['RACK_ENV']
end