require File.join(File.dirname(__FILE__), "..", "config", "boot")
require File.join(File.dirname(__FILE__), "..", "config", "environment")
These two lines setup the rails environment, e.g. ActiveRecord. Your script now has entire Rails/radar set of classes available to it.
The script should be run from application home directory as such:
ruby script/your_script.rb
See script/load_students.rb for an example.
No comments:
Post a Comment