Calling a Rails action from the command line

Anyone knows how to call a Rails action from the command line?

I have an action that would update the database. I can call it from a
web browser:
http://localhost:3000/radar/update_radar

I want to create a cron job that would do this regularly

Thanks

Effie

Effie wrote:

Anyone knows how to call a Rails action from the command line?

I have an action that would update the database. I can call it from a
web browser:
http://localhost:3000/radar/update_radar

I want to create a cron job that would do this regularly

Thanks

Effie
There’s probably a more dignified way of doing it, but…

ruby script/runner ‘require “open-uri”;
open(“http://localhost:3000/radar/update_radar”)’

…ought to do it!

The proper way of doing this is to pull out the update code into a
library
(class under lib/), say RadarUpdater in lib/radar_updater.rb. Then you
can
access it easily from both a Controller and it’s accessible from the
outside.

Your cron-job would look like:

          • ruby /path/to/rails/deploy/script/runner -e production "
            RadarUpdater.run"

and Controller:

def some_action
RadarUpdater.run
end

Jason

ruby script/runner ‘require “open-uri”;
open(“http://localhost:3000/radar/update_radar”)’

…ought to do it!

Without the new line!