title: Problems deploying Sinatra app to staging environment
body: <p>I have a small Sinatra app with both a staging and production environment on a single server with running Nginx.  To deploy I am using Capistrano and capistrano-ext to easily deploy to different locations.</p>
  
  <p>The problem that the staging environment always runs with the production configuration specified within the app.rb file.</p>
  
  <pre><code>configure :staging do
    # staging settings
    set :foo, "bar"   # will never be set to this
  end
  
  configure :production do
    # prod settings
    set :foo, "rab"
  end
  </code></pre>
  
  <p>I have come to the conclusion that the capistrano :environment variable within the deploy.rb file doesn't config Sinatra in any way.  I have also tried setting the ENV["RACK_ENV"] to "staging" to no avail.</p>
  
  <p>config/deploy/staging.rb</p>
  
  <pre><code>server "10.10.100.16", :app, :web, :db, :primary =&gt; true
  set :deploy_to, "/var/www/staging.my_app" 
  set :environment, "staging"
  set :env, "staging"          
  ENV["RACK_ENV"] = "staging" 
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>** Update: I should add that I am also using Passenger.</p>