Script/runner vz Rake tasks
When it comes to running Rails tasks the common question that comes to mind is whether to use script/runner
or to call a rake
task
script/runner long_running_task
VZ
rake long_running_task
To understand it better we need to understand how both works under the hood.
Whenever script/runner
is called it boots the entire Rails
But on the other hand Rake task doesn't load the entire Rails app unless you tell it to by making the task depend on :environment
, like this:
task :some_useful_task => :environment do
# do some useful task
end
Since booting your Rails app is expensive each time, it might be worth skipping if you can avoid it.