How do you avoid Rake task name conflict for dependencies?
-
28-10-2019 - |
题
namespace :jobs do
task :environment => [:environment] do
#Something cool
end
end
This causes a circular dependency on :environment
, which I am just trying to depend on the Rails task environment
.
How can this be correctly setup?
解决方案
You should also be able to say:
task :environment => [ 'rake:environment' ] do ... end
The 'rake:' namespace is the top level namespace. It's like doing ::CONSTANT_NAME in ruby.
其他提示
I have just had exactly the same issue, where a task in a namespace is trying to call a task of the same name in the parent namespace. This is indeed possible.
namespace :jobs do
task :environment => [ '^environment' ] do
#Something cool
end
end
Each caret you use will begin name resolution one level higher in the namespace hierarchy. See: http://rake.rubyforge.org/files/doc/rakefile_rdoc.html
不隶属于 StackOverflow