msmith1114 msmith1114 - 1 year ago 83
Ruby Question

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|

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?


Answer Source

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

bundle exec rake clean_user[123]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download