views:

23

answers:

1

I created a top level directory called 'maintenance' in my Ruby on Rails application. There's mostly scripts there that I use for my own cleanup/project maintenance. I want to be able to load my models and activerecord so I can query them in my script. What do I have to load at the beginning of the script to get it to properly know my environment?

A: 

You can require & setup active record in your scripts but your should use the rails script/runner. You should be able to run all your files directly by adding a hashbang:

#!/usr/bin/env <path_to_your_rails_proj>/script/runner
jdeseno