I have 2 environments, production and staging, and I am using Capistrano with capistrano-ext gem.
When I deploy to staging using Capistrano and restart passenger, I would like the deployed application to run in staging however it runs in the default production
I tried setting:
set :rails_env, "staging"
in my deploy recipe, but this had no effect.
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:
add the following to environment.rb: ENV['RAILS_ENV'] = 'staging'
but this doesn't help me automate the process with Capistrano.
What you are doing when you setting :rails_env, "staging"
environment is setting the environment for the migration. In other words, it's a environment that is only set when you're running capistrano. If I understand you correctly, you want to change the environment when running your app, not deploying.
In order to answer your question, I'll need to know how you are launching (starting) your application.
If you're using Phusion Passenger, you'll need to edit your RAILS_ENV for Passenger
Given that you're in a shared environment, you'll probably want to go with the .htaccess route.