I have a Rails app on production and I want to deploy my app to Staging using Capistrano
before I roll out to production so my team has made a copy of the application on different host which is supposed to act as Staging. I have 2 separate Capistrano environment setups, one for production, the other one for staging. They actually differ by the IP address of the server, the rest is the same standard setup.
I have also added config/evironments/staging.rb
file which is very similar to config.environments/production.rb
with the only difference in
config.action_controller.asset_host
because on Staging I need to load assets from the staging host.
config/environments/production.rb
config.action_controller.asset_host = "my_production_host"
config/environments/staging.rb
config.action_controller.asset_host = "my_staging_host"
but after I do bundle exec cap staging deploy
and inspect the browser console I can see an error 404 Failed to load resource
and it points to the production host assets for some reason.
404 Failed to load resource
<link rel="stylesheet" media="all" href="https://my_prduction_host/assets/application-7d22d41de3a16146e566368364a8b2c769a9ebd68d1333e71d624250fa2fd187.css" />
so it seems it does not read my config/environments/staging.rb
.
config/deploy/staging.rb
server "1.2.3.4", user: "my_user", roles: %w{app db web}, port: 50022
set :stage, :staging
set :rails_env, :staging
Capistrano logs shows current release: current (production)
config/environments/staging.rb
is added to the repo, so why is it not reading my staging configuration? What am I missing? Any idea why it is running the app in production mode?