Skip to content

Instantly share code, notes, and snippets.

@yb66
Created April 15, 2013 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yb66/5388992 to your computer and use it in GitHub Desktop.
Save yb66/5388992 to your computer and use it in GitHub Desktop.
Shared *and* individual configuration in Sinatra.
require 'sinatra'
configure :development do
set :one, 1
end
configure :production do
set :one, 11
end
configure :production, :development do
set :three, 3
end
get "/" do
haml <<STR
%p= "settings.one: #{settings.one.inspect}"
%p= "settings.three: #{settings.three.inspect}"
STR
end
# run `bundle install --binstubs --path vendor`
# and then
# `env RACK_ENV=development bundle exec ruby app.rb` and
# `env RACK_ENV=production bundle exec ruby app.rb`
# to see that you get different `one`s but the same `three`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment