I’m currently working on a new and exciting app, and one issue I ran into is using the app in three different environments.
There’s development where I get to — nay, have to — do all the crazy stuff. The only way to catch bugs is to act like one. There’s staging, experimental but other people also accessing it. And there’s production. Production is for the well behaved.
Three different environments. A UI that looks identical in all three. I sense an accident waiting to happen.
So I added a badge that tells me which environment I’m using right now. Red is for development, yellow for staging, and if I don’t see a badge, must be running in production.
In application layout I added this line:
<%= content_tag :p, RAILS_ENV, class: RAILS_ENV, id: "rails-env" unless RAILS_ENV[/production/] %>
And in the stylesheet I have:
#rails-env { position: fixed; left: 1em; font-weight: bold; padding: .2em 0.9em; text-transform: uppercase; display: none }
#rails-env.staging { color: #000; background: #ffff00; border: 2px solid #cccc20; border-top: none; display: block }
#rails-env.development { color: #fff; background: #ff0000; border: 2px solid #cc2020; border-top: none; display: block }
You can see what it looks like here:

Ennuyer.net » Blog Archive » Rails Reading – Oct 20, 2009