ruby-on-rails – 用于安装仅执行一次的gem迁移的Rake任务

ruby-on-rails – 用于安装仅执行一次的gem迁移的Rake任务,第1张

概述为什么这个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 "\n 为什么这个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  endend

实际上只运行第一组迁移,无论我使用的gems / gem order / random调用reenable?

Installing migrations for the gem1 gem...copIEd migration whatever from gem1copIEd migration whatever from gem1copIEd migration whatever from gem1copIEd migration whatever from gem1Installing migrations for the gem2 gem...(nothing)Installing migrations for the gem3 gem...(nothing)Gem migrations installed.
解决方法 调用方法仅“按需”运行,这基本上意味着一旦运行一次,除非重新启用,否则它不会再次运行.

您可以在每个.invoke之后调用.reenable来重置它,或使用.execute命令来运行任务.

使用.execute的警告是,如果你拥有它们,它将不会运行任务的依赖项.

Why is Rake not able to invoke multiple tasks consecutively?

How to run Rake tasks from within Rake tasks?

总结

以上是内存溢出为你收集整理的ruby-on-rails – 用于安装仅执行一次的gem迁移的Rake任务全部内容,希望文章能够帮你解决ruby-on-rails – 用于安装仅执行一次的gem迁移的Rake任务所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1280956.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存