To make any ruby script run in your rails environment, use script/runner, or add these lines to the top:
require File.dirname(__FILE__) + ‘/../config/boot’
require RAILS_ROOT + ‘/config/environment’
(You might need to do it that way if you’re using Daemonize)