I have a Rails task: should I use script/runner or rake?

The difference between them is that script/runner boots Rails whereas a Rake task doesn’t 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 Rails is expensive, it might be worth skipping if you can avoid it.

Other than that, they are roughly equivalent. I use both, but lately I’ve used script/runner executing a script separately more.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)