user3023421
user3023421

Reputation: 363

Rails rake 'Don't know how to build task '

I am trying to run my rake task in the terminal with multiple arguments, however I keep getting an error:

rake populate:user['a' 'a'] 
DL is deprecated, please use Fiddle
rake aborted!
Don't know how to build task 'populate:user[a'

My rake file:

namespace :populate do
  desc 'Populate data into our database'

  task :user, [:username, :password] => :environment do |t, args|
    // do stuff, also doesn't work when I delete everything inside here
  end
end

I have also tried

rake populate:user[a, a] 

It does run without any parameters:

rake populate:user

Upvotes: 3

Views: 5539

Answers (2)

Anant Kolvankar
Anant Kolvankar

Reputation: 1050

You can try using

rake 'populate:user[a,a]'

Also you can ref https://cobwwweb.com/4-ways-to-pass-arguments-to-a-rake-task

Upvotes: 8

Joshua Pinter
Joshua Pinter

Reputation: 47591

Just remove the space(s) between the arguments.

Use the following:

rake populate:user[a,a]

There shouldn't be any need to add quotes around the entire rake task or around each argument (I don't think).

Upvotes: 2

Related Questions