fgro
fgro

Reputation: 33

Rake task: How to make task from another namespace prerequesite?

rake tasks allow to define a list of other tasks that need to run before as a prerequesite, i.e.

namespace :import do 
 task :products => [:environment, :tax_categories] do
   ... # create products from import and reference tax categories
 end
end

However, how could i reference the tax_categories task if it was defined in another namespace, like

namespace :init do
 task :tax_categories => :environment do
   ... # create tax categories
 end
end

Thanks for the help.

Upvotes: 2

Views: 1080

Answers (1)

rubyprince
rubyprince

Reputation: 17793

You could probably do this, but dont know if this is the recommended way:

namespace :import do 
 task :products => [:environment, "init:tax_categories"] do
   ... # create products from import and reference tax categories
 end
end

Upvotes: 3

Related Questions