所以我在 capistrano 中的 deploy.rb 脚本是这样开始的,我想这很正常:
require 'capistrano/ext/multistage'
require 'nokogiri'
require 'curb'
require 'json'
# override capistrano defaults
set :use_sudo, false
set :normalize_asset_timestamps, false
# some constant of mine
set :my_constant, "foo_bar"
稍后,我可以在命名空间内的函数或任务中访问我的常量,例如:
namespace :mycompany do
def some_function()
run "some_command #{my_constant}"
end
desc <<-DESC
some task description
DESC
task :some_task do
run "some_command #{my_constant}"
end
end
但是,如果我在类中使用常量,如下所示:
namespace :mycompany do
class SomeClass
def self.some_static_method()
run "some_command #{my_constant}"
end
end
end
它失败了:
/config/deploy.rb:120:in `some_static_method': undefined local variable or method `my_constant' for #<Class:0x000000026234f8>::SomeClass (NameError)
我究竟做错了什么??谢谢