Chr*_*ele 4 ruby rake ruby-on-rails ruby-on-rails-3
为什么这个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
Run Code Online (Sandbox Code Playgroud)
实际上只运行第一组迁移,无论我使用的gems/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.
Run Code Online (Sandbox Code Playgroud)
该invoke方法仅"按需"运行,这基本上意味着一旦运行一次,除非重新启用,否则它不会再次运行.
您可以.reenable在每个之后调用.invoke以重置它,也可以使用该.execute命令来运行任务.
需要注意的.execute是,如果你拥有它们,它将不会运行任务的依赖项.
| 归档时间: |
|
| 查看次数: |
927 次 |
| 最近记录: |