diff --git a/README.md b/README.md index 0f234d2..c375698 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Override The Initial Sequence Value](ruby/override-the-initial-sequence-value.md) - [Parallel Bundle Install](ruby/parallel-bundle-install.md) - [Passing Arbitrary Methods As Blocks](ruby/passing-arbitrary-methods-as-blocks.md) +- [Passing Arguments To A Rake Task](ruby/passing-arguments-to-a-rake-task.md) - [Percent Notation](ruby/percent-notation.md) - [Question Mark Operator](ruby/question-mark-operator.md) - [Squeeze Out The Extra Space](ruby/squeeze-out-the-extra-space.md) diff --git a/ruby/passing-arguments-to-a-rake-task.md b/ruby/passing-arguments-to-a-rake-task.md new file mode 100644 index 0000000..0983f1f --- /dev/null +++ b/ruby/passing-arguments-to-a-rake-task.md @@ -0,0 +1,19 @@ +# Passing Arguments To A Rake Task + +You can create a rake task that takes arguments by including an array of +named arguments in the task declaration. + +```ruby +task :greeting, [:name] do |task, args| + puts "Hello, #{args.name}!" +end +``` + +You can then pass an argument to that task when invoking it. + +```bash +$ rake greeting[World] +Hello, World! +``` + +[source](http://davidlesches.com/blog/passing-arguments-to-a-rails-rake-task)