为什么这个rake任务
gems = %w(gem1 gem2 gem3)
namespace :gems do
namespace :install do
desc "Runs install:migrations for all gems"
task :migrations do
gems.each do |gem_name|
print "\nInstalling migrations for the #{gem_name} gem...\n"
Rake::Task["#{gem_name}:install:migrations"].invoke
end
print "\n\nGem migrations installed."
end
end
end
实际上只运行第一组迁移,无论我使用的geng / gem order / random调用reenable?
Installing migrations for the gem1 gem...
Copied migration whatever from gem1
Copied migration whatever from gem1
Copied migration whatever from gem1
Copied migration whatever from gem1
Installing migrations for the gem2 gem...
(nothing)
Installing migrations for the gem3 gem...
(nothing)
Gem migrations installed.
答案 0 :(得分:5)
invoke
方法仅“按需”运行,这基本上意味着一旦运行一次,除非重新启用,否则它不会再次运行。
您可以在每个.reenable
之后调用.invoke
进行重置,或使用.execute
命令运行任务。
.execute
的警告是,如果你拥有它们,它将不会运行任务的依赖项。
Why is Rake not able to invoke multiple tasks consecutively?