First, if possible, you should separate the logic from the data. Determine your environment in your controller, and toggle the data being sent to the view (HAML layout file).
Typically you'd set a flag in your environment variables and access it in your code from ENV
. For instance, Sinatra makes the development/test/production setting available inside the code using their RACK_ENV
symbol:
:environment - configuration/deployment environment A symbol
specifying the deployment environment; typically set to one of
:development, :test, or :production. The :environment defaults to the
value of the RACK_ENV environment variable (ENV['RACK_ENV']), or
:development when no RACK_ENV environment variable is set.
The environment can be set explicitly:
set :environment, :production
If you have to roll your own, that's a good way to go about it.