2012-10-12 4 views
4

이유는 무엇입니까이 레이크 작업레이크 작업 한 번만

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 

실제로 마이그레이션의 첫 번째 세트, 보석/보석 주문/임의 전화가 내가 사용하는 재 활성화하기 위해 상관없이 실행?

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. 

답변

5

invoke 방법은 기본적으로 한 번 실행 된 후에는 다시 활성화하지 않는 한, 그것은 늘 다시 실행하는 것을 의미한다 "필요에 따라"실행됩니다.

.invoke 다음에 .reenable을 호출하거나 다시 설정하거나 .execute 명령을 사용하여 작업을 실행할 수 있습니다.

.execute의주의 사항은 작업이있는 경우 종속성을 실행하지 않는다는 것입니다. 실행하거나. "마이그레이션 : 설치 # {보석}"] : "마이그레이션 : 설치 railties를"작업을 각각의 레이크을

Why is Rake not able to invoke multiple tasks consecutively?

How to run Rake tasks from within Rake tasks?

+0

좋아하지만, 질문에 대한, 다시 활성화 할 필요가 호출, 그리고 모두 괜찮을거야. –