According to “Custom Rake Tasks“:
desc "Pick a random user as the winner"
task :winner => :environment do
puts "Winner: #{pick(User).name}"
end
As far as I know, the :winner => :environment means “do environment before winner“. But what’s environment? When should I use it?
I tried rake -T, but in the list I couldn’t find environment.
You can get access to your models, and in fact, your whole environment by making tasks dependent on the environment task. This lets you do things like
run rake RAILS_ENV=staging db:migrate.See “Custom Rake Tasks“.