title: Setting up secret_key_base on deploy with Capistrano 3
body: <p>So I'm deploying to a Ubuntu droplet hosted on DigitalOcean a Rails 4 application running on Apache and Phusion Passenger. After deployment I've been getting 500s as a result of Rails production not finding the <code>secret_key_base</code> token for production. However, if I run an <code>echo $SECRET_KEY_BASE</code> it returns the rake secret generated by my deploy.rb.</p>
  
  <p>The deploy.rb task to set that up is:</p>
  
  <pre><code>namespace :deploy do
    task :start do ; end
    task :stop do ; end
  
    desc "Setup ENV variables"
    task :env_vars do
      on "root@xxx.xxx.xxx.xx" do
        execute "export SECRET_KEY_BASE=#{`bundle exec rake secret`}"
      end
    end
  end
  
  before "deploy", "deploy:env_vars"
  </code></pre>
  
  <p>However, Rails is still not picking it up. I even ssh'd into my server and in <code>rails console</code> checked and <code>ENV["SECRET_KEY_BASE"]</code> returns the correct secret token.</p>
  
  <p>I thought using Capistrano's <code>:default_env</code> would work, but that only seems to set up environmental variables for the deploy task, but not actually on the server. Is there any easy way to solve this solution? My fallback is to just place the secret within <code>secrets.yml</code> since the repo is private, but I rather not do that.</p>