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_taskis the name of the task you are calling.For instance, in this case, you will call
rake some_taskYou also could define namespaces for your tasks :
And then you will call
rake my_tasks:first_taskin your console.Hope it will help you,
Edit:
As explained by Holger Just, the
:environmentexecutes 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.