Friday, 6 September 2013

Rake task w/ splat arguments

Rake task w/ splat arguments

I'm attempting to create a rake task that takes a required first argument,
and then any number of additional arguments which I want to lump together
into an array:
rake course["COURSE NAME", 123, 456, 789]
I've tried the following but args[:numbers] is simply a string w/ 123
instead of all of the numbers.
task :course, [:name, *:numbers] => :environment do |t, args|
puts args # {:name=>"COURSE NAME", :numbers=>"123"}
end

No comments:

Post a Comment