Daily Jobs in Rails

Hi railers,

I have a quick question - I think it will be answered fairly easily

What’s the best practice (naming conventions, where to place in
project etc) for creating a job to be ran every day?

For example - want to run a ruby script to grab an xml feed and
persist it in a database.



On 5/22/08, chalkers [email protected] wrote:

persist it in a database.
Put the job in the model. then run it with script/runner, via cron or

script/runner -e production Foo.daily_task

Greg D.

That’s bloody fantastic! Thank you.

You can find a couple alternative solutions here:


I suspect Andrew’s solution at the bottom of that post is probably
best. Better than mine yes:-)

good luck!

That seems a better alternative. Didn’t seem quite right in the model,
and in the controller it’s a bit out of place. Tasks sounds like what
the thing is. A task :slight_smile:

Thanks Tim, that sounds a great alternative - putting things in tasks
in tasks and actions in a controller! Simple, logical. Model was a bit
out of place for what I needed.

I think the point Andrew was making was to take the code out of the
controller and put it in a task. As opposed to what the john was
doing by having the code in a controller and calling it with curl.

I agree that the model doesn’t feel like a good place for this kind of

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs