Does Rails run initializers for rake task?

Paul picture Paul · Jul 16, 2012 · Viewed 7.4k times · Source

Are the scripts from config/initializers executed when I run rake task?

Answer

MrDanA picture MrDanA · Jul 16, 2012

It does if your rake task depends on :environment.

i.e, you declare your task like so:

task :my_task => :environment do
     ...
end