我在capistrano写作rake任务。
我认为我可以在info
method1
和method2
run_locally
中使用method2
方法,但我在info
中收到了错误。< / p>
发生了什么......
如何解决此问题?
我应该在run_locally
再次将Sample:method2
与namespace :sample do
task :task1 do
run_locally do
method1('task1')
Sample::method2('task1')
end
end
def method1(str)
info "> called method1 str:#{str}"
end
end
module Sample
extend Rake::DSL
extend self
def method2(str)
info "> called method2 str:#{str}"
end
public :method2
end
一起包裹吗? (但我拒绝了......)
环境
码
$ bundle exec cap beta sample:task1
INFO > called method1 str:task1
(Backtrace restricted to imported tasks)
cap aborted!
NoMethodError: undefined method `info' for Sample:Module
/capistrano/lib/capistrano/tasks/util.rake:22:in `method2'
/capistrano/lib/capistrano/tasks/util.rake:8:in `block (3 levels) in <top (required)>'
/capistrano/lib/capistrano/tasks/util.rake:6:in `block (2 levels) in <top (required)>'
Tasks: TOP => sample:task1
(See full trace by running task with --trace)
输出
index.html