I have 2 jobs I would like to run and they are dependant on Models in my rails application. I added the ruby files in a separate folder called Jobs, that I have appended to
Use rails runner
$ rails -h
Usage: rails COMMAND [ARGS]
...
runner Run a piece of code in the application environment
All commands can be run with -h for more information.
The "Rails 3 way" to do this is with Rake using the :environment
prerequisite, which loads the Rails environment. Like so:
task :name => :environment do |t|
# actions
end
In the block you can load and execute your jobs.
If you haven't written Rake scripts before, here's a good tutorial. It's quite easy.