Passing command line arguments to a rake task

Creating a rake task
desc "Description of what this task does"
  task :myraketask => :environment do
  ..
  ..
  end
Once you have created a rake file(File with extension as .rake) and placed in /lib/task folder in your application.You can check
rake -T
for all the avaliable tasks, Your custom task will also be listed here with the description you have mentioned.
So this is the general way of using your rake task.
rake myraketask 
And if you wanted to pass any sort of arguments to your rake task , you can do this by
rake myraketask foo=bar 
So the argument foo can be accessed by
ENV['foo']
in your task.

Comments

Popular posts from this blog

Inserting and Moving elements inside Ruby Array

Difference between Validations, Callbacks and Observers