1

I have want to set this deferred variable in Capistrano which depends on some variable I set during calling the task

set(:installation_dir) do 
    if target == "staging"
        "/some/path"
    else
        "/some/other/path"
    end
end

task :foo do
    p "INSTALLATION_DIR >>> #{installation_dir}"
end

If running the task this error happens

Hector:monitoring-agent robertj$ cap foo -s target=development
/Users/robertj/.rvm/gems/ruby-2.0.0-p0@pf/gems/capistrano-2.15.4/lib/capistrano/configuration/variables.rb:122:in 
`method_missing_with_variables': undefined local variable or method `target' for 
#<Capistrano::Configuration:0x007fd6a22f9100> (NameError)

This is making me mad. Why doesnt Capistrano 2.x have a simple way to access variables where ever I call.

4

2 に答える 2

1

どうやら、fetchやりたいことをやる

p "INSTALLATION_DIR >>> #{fetch(:installation_dir)}"
于 2013-11-05T11:10:18.697 に答える