Skip to main content

rails

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!

Restarting a rails app on shared hosting

Posted in

I don't work in Rails very much these days, so when I do go back to it I get frustrated that I've forgotten even the most basic principles and techniques.

If you've made tweaks to a Rails app and need to reload the cached version of the site, use the following commands to first find the process id (pid) of the dispatch.fcgi job, then kill that process:

  1. ps aux | grep ruby
  2. kill -USR2 [pid]

 

Syndicate content