Search code examples
ruby-on-railsrubyrake

Rake task loading in Working Directory?


So I have a pretty simple rake task, it looks like such:

#Clean User
 desc "Wipes User"
 task :clean_user, [:emp] => :environment do |t, args|
 Core::User.find(args[:emp]).destroy
end

Simple right? Essentially it takes in a ID and wipes the user. So I run the rake task as bundle exec rake clean_user 123

The 123 is just any sample number, however the weird thing is the error I get back, which essentially says:

"Error could not find user with ID = My Working Directory Path"

Of course replace My Working Directory Path with /usr/me/documents/folders/etc....

This makes no sense? It's like it's not taking in the actual 123 number? Are my arguments setup wrong for taking in Parameters from Command Line?

Thanks


Solution

  • Rake task arguments are not passed like that on the command line. Try this:

    bundle exec rake clean_user[123]