Take the 2-minute tour ×

Why does this rake task

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"
      print "\n\nGem migrations installed."

only actually run the first set of migrations, no matter the gems/gem ordering/random calls to reenable I use?

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...

Installing migrations for the gem3 gem...

Gem migrations installed.
share|improve this question

1 Answer 1

up vote 5 down vote accepted

The invoke method only runs "as needed", which basically means that once it's run once, it wont run again unless reenabled.

You can either call .reenable after each .invoke to reset it, or use the .execute command to run the task.

The caveat with .execute is that it won't run the dependencies for the task if you have them.

Why is Rake not able to invoke multiple tasks consecutively?

How to run Rake tasks from within Rake tasks?

share|improve this answer
ok, but, about question, need to reenabled "railties:install:migrations" each Rake::Task["#{gem}:install:migrations"].execute or invoke, and all be fine. –  Bruno Guerra Jan 18 '13 at 0:51

Your Answer


