Skip to main content

Running scripts with rails script/runner

Posted in

Lately I've been needing to write short Rails scripts to make changes and updates to items in the database and associated images. I repeatedly tried to create a freestanding script and then run it with "ruby script/runner [script-name]," to no avail.

In the end, my solution was just to put the script into the model file of one of my objects, then run it with "ruby script/runner [Object].[method]" -- this worked like a charm!

(I don't know if these problems are a side effect of the fact that this Rails project is running on a very old version of the software -- I don't remember having problems like this when I was setting up cron jobs and the like several years ago.)