Anthony,

This is an easy one, the problem is - not scope as you might think, but
rather the order in which the files are loaded.

You can get this working, by using a Proc (more
info<http://www.ntecs.de/old-hp/s-direktnet/ruby/uguide18.html>)
which will ensure that the block you assign isn't evaluated until you first
use it... so this:

   - ./deploy.rb:
   role :app, "#{application_domain}" #mongrel server
   role :web, "#{application_domain}" #apache server "qa.example.net"
   role :db,  "#{application_domain}", :primary => true #database server
   (where migrations are run)

Becomes this:

   - ./deploy.rb:
   role :app, { application_domain }     #mongrel server
   role :web, { application_domain }    #apache server "qa.example.net"
   role :db,   { application_domain}, :primary => true     #database server
   (where migrations are run)

Note firstly, i've stopped them being an interpolated string - there's no
point, unless it's part of a longer string, in this instance, it isn't - but
more importantly they're being passed as a block (thus the {}) which is
shorthand for a proc... it basically means that what you have assigned to
:app is a mini-anonymous function that returns "application_domain" when you
run (access) it.

-- Hope that helps, there's a little more reading, actually in the
multistage faq, if memory serves - thogh you could be excused for having
overlooked it :)

-- Lee H

2008/11/2 Anthony Ettinger <[EMAIL PROTECTED]>

>
> I want to use a variable in deploy.rb that is defined in ./deploy/stage.rb
>
> ./deploy.rb:
> role :app, "#{application_domain}" #mongrel server
> role :web, "#{application_domain}" #apache server "qa.example.net"
> role :db,  "#{application_domain}", :primary => true #database server
> (where migrations are run)
>
> ./deploy/stage.rb
> set :application_domain, "#{application}" #example.com
>
> ./deploy/qa.rb
> set rails_env, 'qa'
> set :application_domain, "#{rails_env}.#{application}" #example.com
>
>
> However variables defined in ./deploy/stage.rb files aren't accessible
> from the general ./deploy.rb script.
>
> --
> Anthony Ettinger
> 408-656-2473
> http://anthony.ettinger.name
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to