In Rake task definition, like following:
desc 'SOME description'
task :some_task => :environment do
# DO SOMETHING
end
What does the :some_task
in task :some_task => :environment
means?
Is it the method name which will be invoked in the DO SOMETHING
part?
Can :some_task
be any arbitrary string which describe the task?
In fact, when you're creating a rake task, :some_task
is the name of the task you are calling.
For instance, in this case, you will call rake some_task
You also could define namespaces for your tasks :
namespace :my_tasks do
desc "My first task"
task :first_task => :environment do
# DO SOMETHING
end
end
And then you will call rake my_tasks:first_task
in your console.
Hope it will help you,
Edit:
As explained by Holger Just, the :environment
executes the "environment" task and if you are on rails, loads the environment. This could take a long time but il also helps you if your tasks works with the database.