ENV vars: A better way to pass arguments to rake tasks in Rails

Today, I happened upon a situation where I needed to pass an argument into my rake task. In the past I've passed an argument using an array-like syntax like like this post describes. While this works, I didn't really like the syntax and it didn't seem very natural in the command-line.

Calling a task like this doesn't seem as readable as it could be. rake seeder:seed[100,someString]

I've found a solution that I like better that utilizes a method from Thoughtbot in their Paperclip gem.

Set an environment variable as part of your rake task command, then look for that ENV var during the task.

Then look for the env var in the task itself.

It's simple and a lot more readable than passing in an array of arguments.