title: Deploy rails app to production, why still using environment staging?
body: <p>I have deploy my rails app to production, but why it still using environment staging, my rails app still connect to staging database,link url still forward to staging app like email confirmation it should connect to production app. </p>
  
  <p>I'm deploy using capistrano, puma, my server using nginx</p>
  
  <p>Is there something missing ???</p>
  
  <p>This is database.yml code</p>
  
  <pre class="lang-rb prettyprint-override"><code>development:
    encoding: utf8mb4
    collation: utf8mb4_unicode_ci
    adapter: mysql2
    database: database_development
    pool: 5
    username: root
    password: 123456
  
  staging:
    host: 127.0.0.1
    encoding: utf8mb4
    collation: utf8mb4_unicode_ci
    adapter: mysql2
    database: database_staging
    pool: 8
    username: root
    password: &lt;%= ENV['RAILS_DB_PW'] %&gt;
  
  test:
    encoding: utf8mb4
    collation: utf8mb4_unicode_ci
    adapter: mysql2
    database: database_test
    pool: 5
    username: root
    password: 123456
  
  production:
    encoding: utf8mb4
    collation: utf8mb4_unicode_ci
    adapter: mysql2
    database: database_production
    pool: 60
    username: root
    password: &lt;%= ENV['RAILS_DB_PW'] %&gt;
  </code></pre>
  
  <p>This is production.rb code</p>
  
  <pre class="lang-rb prettyprint-override"><code>set :application, 'my rails app'
  set :stage, :production
  set :rails_env, 'production'
  
  set :deploy_to,  "/var/#{fetch(:user)}/#{fetch(:application)}"
  set :server_name, "my-rails-app.com"
  
  set :delayed_job_args, "-n 4"
  
  # http://stackoverflow.com/questions/21036175/how-to-deploy-a-specific-revision-with-capistrano-3
  set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || 'master'
  
  role :app, %w{deploy@1.2.3.4}
  role :web, %w{deploy@1.2.3.4}
  role :db,  %w{deploy@1.2.3.4}
  server '1.2.3.4', user: 'deploy', roles: %w{web app}
  </code></pre>
  
  <p>This is deploy.rb code</p>
  
  <pre class="lang-rb prettyprint-override"><code>
  lock "~&gt; 3.11.0"
  
  set :application,       "my-rails-app"
  set :repo_url,          "git@github.com:user/my-rails-app.git"
  set :user,              'deploy'
  set :puma_env,          'staging'
  set :puma_threads,      [1, 16]
  set :puma_workers,      1
  
  set :rvm_ruby_version, '2.4.1'
  
  set :ssh_options, { forward_agent: true, auth_methods: %w(publickey) }
  
  set :deploy_via,      :remote_cache
  
  set :ssh_options,   { forward_agent: true, auth_methods: %w(publickey) }
  
  set :linked_files, %w{.env config/master.key config/database.yml}
  set :linked_dirs, %w{log tmp/cache tmp/sockets tmp/export tmp/pids public/assets public/uploads config/locales/field_translation/medical_category}
  
  SSHKit.config.command_map[:rake] = 'bundle exec rake'
  SSHKit.config.command_map[:runner] = 'bundle exec rails runner'
  SSHKit.config.command_map[:sidekiq] = "bundle exec sidekiq"
  
  namespace :deploy do
    desc 'Restart application'
    task :restart do
      on roles(:app), in: :sequence, wait: 5 do
        execute :touch, release_path.join('tmp/restart.txt')
      end
    end
  
    after :publishing, :restart
  
    desc 'Initial Deploy'
    task :initial do
      on roles(:app) do
        before 'deploy:restart', 'puma:start'
        invoke 'deploy'
      end
    end
  
  end
  </code></pre>
  
  <p>Thanks </p>