Supply arguments to a rake task
Whilst working on a recent project, I wanted to create a rake task that would send a curl request to a
particular url. It was a pain to keep changing the resource id, so I decided to write a rake task that could accept the resource id as an argument.
For anyone looking to do something similar, it’s actually quite simple.
The above task, when invoked, simply POSTS the contents of the file ‘sample_payload.json’ to the given url.
It is called like this, where 50fdbac236974c8983000001 is the argument to be supplied; in my case, the _id of a MongoDB row.
One little gotcha for ZSH users is that it must be quoted, like this