user2158382
user2158382

Reputation: 4520

Rake task with multiple parameters and model access not working

I am getting the following error running my rake task

rake store_reports["1", "2"]
rake aborted!
Don't know how to build task 'store_reports[1,'

My rake task takes 2 parameters and needs to access models inside it. Here is the task

task :store_reports, [:start_date, :end_date] => :environment do |t, args|
    puts args.start_date
end

I referenced both of there stackoverflow questions, but the first answer did not work, and in the second one the author seems to have solved it but he never posted his answer.

rake aborted! undefined method `map' for :name:Symbol rake task with multiple parameters - I got stuck

Heres some extra info. Where I run rake -T I dont see my rake task there

Upvotes: 17

Views: 4467

Answers (1)

Anko
Anko

Reputation: 1332

try

rake store_reports["1","2"]

as per How to pass command line arguments to a rake task.

the parser is not liking the space between your parameters

Upvotes: 26

Related Questions