title: Set application name on stage files on capistrano
body: <p>I'm trying to deploy my application with the multistage/ext estensions. It works fine when each stage is in different servers. But for one particular proyect I want to deploy two stages to the same server.</p>
  
  <p>For that I need to set a different application name on each server. And that is what isn't working.</p>
  
  <p>I moved the <code>application</code> variable to the stage file and define the <code>deploy_to</code> variable with lazy loading.</p>
  
  <h3>config/deploy.rb</h3>
  
  <pre><code>set :stages, %w(production beta)
  set :default_stage, "beta"
  require 'capistrano/ext/multistage'
  
  #set :application, "myapp-beta"
  set :user,        "deploy"
  set (:deploy_to)  { "/home/#{user}/applications/#{application}" }
  </code></pre>
  
  <h3>config/deploy/beta.rb</h3>
  
  <pre><code>server "my.server.com", :web, :app, :db, primary: true
  
  set :application,  "myapp-beta"
  set :domains,      "beta.myapp.com"
  set :branch,       "beta"   
  </code></pre>
  
  <p>I get <code>Please specify the name of your application, set :application, 'foo'</code> error </p>
  
  <p>Maybe I should be thinking about deploying to a different server, but now I really want to understand why this isn't working.</p>
  
  <p>thanks</p>