title: Setting the Ruby on Rails application environment using Capistrano on Phusion Passenger
body: <p>I have 2 environments, <em>production</em> and <em>staging</em>, and I am using Capistrano with capistrano-ext gem.</p>
  
  <p>When I deploy to <em>staging</em> using Capistrano and restart passenger, I would like the deployed application to run in <em>staging</em> however it runs in the default <em>production</em></p>
  
  <p>I tried setting:</p>
  
  <pre><code>set :rails_env, "staging"
  </code></pre>
  
  <p>in my deploy recipe, but this had no effect.</p>
  
  <p>I am aware this can be done by setting a virtual host in Apache, but I am using shared hosting, so don't have access. My host offers this advice:</p>
  
  <blockquote>
    <p>add the following to environment.rb: ENV['RAILS_ENV'] = 'staging'</p>
  </blockquote>
  
  <p>but this doesn't help me automate the process with Capistrano.</p>