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.
Capistrano is a tool for deploying applications using deployment scripts. To perform deployments, you can use predefined tasks or create custom Rake tasks. RubyMine allows you to quickly run Capistrano tasks with double Ctrl and configure Capistrano run options using run configurations.
Capistrano is a framework for building automated deployment scripts. Although Capistrano itself is written in Ruby, it can easily be used to deploy projects of any language or framework, be it Rails, Java, or PHP.
How does Capistrano work? Capistrano is a framework written in Ruby that provides automated deploy scripts. It connects to your web server via SSH and executes a bunch of tasks that will make your app ready to shine.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With