script/runner allows one to execute long running processes
by either running Ruby code or access the models directly.
For example, say you have some code like the following in your model code:
class NewsFeed << ActiveRecord::Base
def self.download_feeds
# TODO: The code to download the feeds and put them in the database
end
end
Say you want to run download_feeds on the commandline, you can by
running the following on the shell.
script/runner NewsFeed.download_feeds This is useful if you need to run something regularly. So you can put
this in a cron file to execute regularily, like downloading news.
Comments [0]