Need to run controller code periodically in the background

I need to invoke certain portions of my controller periodically in the
background without any user initiation [through views].

Currently, I hack this by using an unit test - obviously this wont work
in a production environment.

Is there a way to invoke / post requests to a controller [with login
and all] outside of the testing framework?

Any help would be appreciated.

anand

well that depends what you want excatly.

  • the plugin “backgroundrb” can run tasks periodically i guess, outside
    of rails in a new thread.

  • ActionView’s Prototype Helper “periodically call remote” can make
    periodical AJAX calls to a controller

Thanks Thorsten.

I will check out backgroundrb.

Joe

Dumb question - so the code in lib has access to rails infrastructure,
as in full access to models and querying etc?

anand

I would code up a function and put it in /lib, then use cron
script/runner to execute it. No having to mess with logins, etc.

Joe