Forum: Ruby Rake tasks with parameters

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
13 (Guest)
on 2006-04-28 18:51
(Received via mailing list)
Hi,

I have some Rake tasks (actually these are Rails tasks to load db
fixtures) that take parameters, for example:

  $ rake db:fixtures:load FIXTURES=foo,bar

What is the best way to make this type of task as dependency for some
other task ? Now I do  it this way:

task :setup => [:clean, :migrate, :load_foo_and_bar]

task :load_foo_and_bar do
  ENV['FIXTURES'] = 'foo,bar'
  Rake::Task['db:fixtures:load'].invoke
end

Maybe there is some cleaner way to do this kind of stuff ? BTW I don't
get any error information to stdout if load_foo_and_bar fails.
This topic is locked and can not be replied to.