Effecting way to write a cron using Ruby On Rails

3 views
Skip to first unread message

Pavan Agrawal @ Ruby On Rails

unread,
Jan 25, 2008, 5:53:07 AM1/25/08
to rubygems
I recently had to create a cron job that controlled the delivery of
newsletters to a set of subscribers. Unfortunately, the code required
some refactoring, but up until it could be modified, the task still
needed firing at specific intervals.

I had a little trouble finding much on this subject, so here is the
code I eventually used:

./script/runner -e production "app =
ActionController::Integration::Session.new; app.get 'account/
send_newsletters'"

With any luck, this will help another person save a couple of minutes!
Update

Since Rails 1.2, this method of executing rails controller actions has
been throwing an "uninitialized constant
ActionController::Integration" exception. Adding the following line to
your environments.rb file fixes this problem:

require 'action_controller/integration'

Thanks, Dimitry Hristov!


--
Pavan
Reply all
Reply to author
Forward
0 new messages