Hidden in plain sight: script/runner

I am loving the opportunity to work with my co-workers in the home office. We have "geek-out" lunches in the office once a week or so, and invariably all learn something.

So today I learned about script/runner, a file that's in every Rails app that I never looked into for some reason. Turns out I wish I had. It's a replacement for calling the Ruby interpreter that gives your script your app's Rails environment preloaded, so you can just write Ruby code without having to monkey around with loading Rails yourself. Just call something like

script/runner my_file.rb


script/runner "puts 'My Ruby code here'; puts MyModel.count".

What are your favorite "hidden-before-your-eyes" features of Rails?