sites
sites

Reputation: 21775

Capistrano environment variable

I saw this Capistrano: Can I set an environment variable for the whole cap session?

And I am using this to set my variable

  set :default_environment, self[:default_environment].
    merge('PAYPAL_SANDBOX' => 'true')

I print self[:default_environment] and I get PAYPAL_SANDBOX correctly set

However, how could I test if rails server is running with that variable set?, I think is not working, because in another part I have

ENV['PAYPAL_SANDBOX'] ? 'development' : Rails.env

and I am getting into second part of this sentence, I mean is taking Rails.env instead of development

Upvotes: 3

Views: 2203

Answers (2)

Tamer
Tamer

Reputation: 33

My solution was like this:

  1. Set global variable

    set :my_number, 23

  2. Get global variable

    puts "My number is #{fetch(:my_number)}"

Upvotes: 0

sites
sites

Reputation: 21775

I solved it like this:

  1. I created a file inside my server, just to mark it

    touch test_server
    
  2. Inside an initializer

    TEST_SERVER = `ls ~/test_server`.present?
    
  3. Then,

    TEST_SERVER ? 'development' : Rails.env
    

Upvotes: 2

Related Questions